All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag like sql-server-2016 if that is relevant to the question.

learn more… | top users | synonyms (2)

10
votes
2answers
8k views

SQL Server LocalDB Instance; error restoring backup (MasterDBPath not available)

I have SQL Server 2012 Local DB Installed, and am connecting to it via (localdb)\v11.0. When trying to restore a backup file, I get: TITLE: Microsoft SQL Server Management Studio Property ...
5
votes
2answers
354 views

Need for reaching data through clustered index with a non-clustered index

I have found that when a table has both clustered and non-clustered indexes (on different columns), the leaf level non-clustered pages, instead of pointing to the data row, point to the node of the ...
7
votes
2answers
11k views

SQL Server Express vs. Oracle Express Edition vs DB2 Express-C

I have been trying to compare the features of the SQL Server Express, Oracle XE and DB2 Express-C, but find it difficult to compile all the differences into one place. Especially the current ...
6
votes
2answers
7k views

SQL Server: Log Shipping Read Only

When log shipping between a primary database and a secondary database, does the secondary database have to be set to read-only? By read-only, I am not talking about the idea of only reading from the ...
8
votes
2answers
3k views

How to backup/restore SQL Server database from command line similar to mysql

I need to automate the migration for some databases from an older server. I know that script a tool using C# for example can be a possibility but I need a simple, fast and effective solution in order ...
3
votes
1answer
3k views

What are the most compelling reasons to upgrade from SQL Server 2005 to SQL Server 2012?

We currently have 2 SQL Server 2005 Enterprise machines in a mirrored environment running on Dell R815 servers. These machines consist of: Four AMD Opteron 6176 Processors (12 cores at 2.3Ghz), for ...
7
votes
1answer
9k views

Microsoft SQL Server 2008 R2 backup error

I'm trying to do a simple backup to an external disk and getting this error: Backup failed for Server 'Server-name' Additional information: System.Data.SqlClient.SqlError: The media loaded ...
8
votes
2answers
14k views

Why is this query not using my nonclustered index, and how can I make it?

As follow up to this question about increasing query performance, I'd like to know if there is a way to make my index used by default. This query runs in about 2.5 seconds: SELECT TOP 1000 * FROM [...
3
votes
1answer
1k views

Using Service Broker internal to a single SQL Express instance?

I understand that SQL Express cannot send Service Broker messages to other instances without a Standard (or better) instance involved in the chain. But is it possible to use Service Broker to send ...
11
votes
3answers
9k views

Merge statement deadlocking itself

I have the following procedure (SQL Server 2008 R2): create procedure usp_SaveCompanyUserData @companyId bigint, @userId bigint, @dataTable tt_CoUserdata readonly as begin set ...
12
votes
4answers
5k views

Is it possible to increase query performance on a narrow table with millions of rows?

I have a query that is currently taking an average of 2500ms to complete. My table is very narrow, but there are 44 million rows. What options do I have to improve performance, or is this as good as ...
2
votes
0answers
335 views

end user complaining poor performance of a query or application in SQL server [closed]

Any suggestions on what set of questions I should be asking an end user or an application user to drill down to the real issue of his complaining about slow responses to his queries? For example: ...
4
votes
2answers
398 views

SQL Server Transaction Log Initial Data Load

What is the standard process when initially populating a database with 5GB+ to avoid a large transaction log? From my understanding the log file would jump to a large size after the initial load and ...
7
votes
1answer
1k views

De-Cluster SQL Server 2012

Is there any way to 'de-cluster' an instance of SQL Server 2012 that was installed using the 'New SQL Server Cluster Installation' option? We are having issues with the failover portion of clustering ...
9
votes
2answers
2k views

Other than restarting SQL Server, is there any way to force the SQLCLR AppDomain to be reset?

I want to force the AppDomain being used by SQLCLR to be reset. How can I do that besides restarting the SQL Server instance?
6
votes
1answer
480 views

SQL Server index / performance help needed (index scan and a sort taking 40 minutes)

I finally have the logic figured out for a query, now I need to speed it up... dramatically, if possible (it runs for 40 minutes +/-). It's on two tables, one with just a couple hundred rows (...
3
votes
1answer
342 views

SQL Server 2008 log shipping via JungleDisk

Has anyone used Jungle Disk as a common location for SQL Server 2008 log shipping? We use it for backup already and I think it can be used for taking log backup to our off-site location. It seems ...
3
votes
1answer
994 views

Connecting to an SQL server instance without using square brackets to avoid backslash

In our company we have an old piece of software which was written by our previous I.T manager but was never finished. The program connects to SQL server but we want it to point to a newer SQL server ...
4
votes
1answer
138 views

What mechanisms do you use to notify third parties of future schema changes?

How do you notify third parties of future SQL Server schema changes other than through external documentation? I've started implementing a deprecation warning extended property on objects that will ...
2
votes
1answer
682 views

Rules in SQL Server 2005

The syntax for rules in SQL Server 2005 is given: CREATE RULE [ schema_name . ] rule_name AS condition_expression Whenever using rule, for example: CREATE RULE list_rule AS @list IN ('1389', '...
5
votes
2answers
913 views

How can I change the target server type for a trace template?

I've got a .tdf SQL Server Profiler trace template someone wants me to run but the template is targeting SS 2008 R2. While my SSMS is 2008 R2 the server I need to trace is SS 2005. When attempting to ...
2
votes
1answer
371 views

Incremental Database/Data Change Restore

I have vendor production backup that needs to be restored onsite daily. The most frustrating part is that their installation is on SQL 2008 but the DB mode is SQL 2000. sigh!!! The database in our ...
1
vote
2answers
488 views

Is Log Shipping or Mirroring a better solution for Disaster Recovery?

I am planning an index rebuild, however my logs are prone to huge overblown sizes. In fact I was leaning towards doing an intelligent re-indexing, but since the fragmentation levels are greater than ...
9
votes
2answers
4k views

Why should a CTE start with a semi-colon?

I was just looking at a post on SO (http://stackoverflow.com/questions/12183062/how-to-ensure-contiguity-of-a-tally-table) where Aaron Bertrand proposes using a CTE instead of a numbers table, which ...
3
votes
3answers
486 views

selecting multiple instances of a record based on record lifespan over years

I have a table of items that have a origin date and a life span. I want to create a procedure that selects all of the items that will need to be replaced in a specific duration. I feel like there is a ...
3
votes
3answers
237 views

What SSMS and/or Visual Studio tools sync SQL Server environments?

I need to sync table structures, stored procedures, triggers, data, etc. between environments. There are dev, QA, and production environments. I am in a Microsoft-centric environment. What tools ...
2
votes
1answer
4k views

PAD_INDEX and FILLFACTOR on clustered Identity index

I am trying to work out what setting for PAD_INDEX I should use for a clustered index on a IDENTITY column, the table is rarely going to be updated after first insert so I am looking for the setting ...
4
votes
2answers
674 views

Many to Many Relationship Question

I have a database, with one main table: Project, and about 10 other tables (Entity1, Entity2, etc.) Each of the different entities can belong to one or many projects. I know I can have tables like ...
2
votes
1answer
255 views

Sql Server And Very Hot CPU % of Total Wait Time

I have recently started monitoring a production database with transactional replication. The CPU % of Total Wait time = %93.00. This is horrible. I confirmed all 8 processors are being utilized. This ...
6
votes
3answers
34k views

“lock request time out period exceeded” Error When Trying to See DB Hierarchies

I'm having problems with a database. I can run basic queries, albeit much slower than normal. When I attempt to view the hierarchy trees for tables, views, or procedures in SSMS Object Explorer, I ...
2
votes
0answers
2k views

Can't Restore DB Because of Active Connections [closed]

I have a DB I would like to restore. There are other active connections on the DB. I tried using sp_who2 to find those connections and manually kill them. Unfortunately, this did not solve the ...
2
votes
1answer
520 views

Cross Apply without a function

I would like to run a query very similar to this on one of my production databases: -- Setup the table (Already there in my real scenario) create table dbo.MyTable(MyValue int, MyGroup varchar(5)) ...
8
votes
2answers
19k views

Sql Server - Best Practices for Growing Database Files

I have been monitoring file growth via the data collector in sql server 2008 r2 for two weeks. The database is growing consistently at around 35(MB)/Day. The DB has not yet hit the initial size of 2 ...
3
votes
1answer
1k views

How do you connect to SQL Server 2008 Express when SA is disabled?

I'm trying to create a database in SQL Server 2008 Express (as installed by Visual Studio) but I don't seem to have any permissions to do so. There must be a way to do this, or there would be no point ...
1
vote
1answer
218 views

Querying multiple tables

I am working on a query from our ticketing system, and I am having problems figuring out the best way to join these tables together. I have the following tables/fields: SR_service: stores ticket ...
7
votes
1answer
407 views

Is it possible to limit the maximum disk usage for a user

Is it possible to set a limit on the amount of physical disk space a user (or group of users) can use within a single database? For example is there some method of associating a schema with a ...
0
votes
2answers
203 views

SQL Server database encoding

My database in SQL Server 2008 went into suspect mode, and I fixed it by changing to emergency mode then I used this query DBCC CHECKDB (Test, REPAIR_ALLOW_DATA_LOSS); And now my data letters in my ...
4
votes
2answers
1k views

Are there any way to stop typing 'go' in sqlcmd?

If I remember correctly, last time Microsoft Sqlcmd require each command to end with ';' and hit Enter key to execute the command. However, currently, we need to type the GO each time to execute the ...
2
votes
2answers
1k views

SQL Partioning on date, how does it work for future records?

I am setting up a new system and I would like to partition the data for speed. Basically what I would like to do is have one database with all the latest information (e.g. last 3 months). then have ...
0
votes
3answers
125 views

How to convert query results into groups of common results

I have a query that returns results like this: MyValue MyGroup _______________|_______________ 56 | I _______________|_______________ 12 | I ...
0
votes
2answers
703 views

Convert datetime to europe default without time

I have a datetime field that I need to convert into the format DDMONYY (27Aug12). I am currently using convert(nvarchar(30),DateToConvert,13), but that also spits out the time. How can I easily ...
4
votes
1answer
6k views

T-SQL: Convert XML to string without self-closing tags

We have a weirdo system we're integrating with which consumes XML, but it does not understand self-closing tags, so <BOOKING> <BOOKINGID>56812</BOOKINGID> <PERSONCODE /> &...
6
votes
2answers
707 views

Performance tuning for gap analysis of table

I have a table which stores the sequence (counter) of data received from devices out in the field. At any rate, these sequences need to be in order within a configurable time span, but can come into ...
0
votes
2answers
2k views

Secure way to connect: Windows Authentication or SQL Server Authentication and why?

Which is the best way to create a connection string for SQL Server? Should I be using a trusted connection string (windows authentication) or an untrusted connection string (sql server authentication)...
7
votes
2answers
297 views

High rise in SQL Server CPU after adding a DB

I have just added a "new" DB to my Server (2005), I have restored from a dead SQL2000 server to my active one (2005), and changed the compatibility to 90 (SQL Server 2005). My average CPU was on 48% ...
4
votes
2answers
11k views

Why database diagrams are not working when domain account is attached to database owner?

I was trying to use Database diagrams is SQL Server and got following error: Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first ...
2
votes
1answer
420 views

Schema for 1 <-> 0..1(+), many related but only one primary

Using tools available in SQL Server 2008 and Entity Framework, what is a solid way to represent a one-to-many relationship, where there is an underlying unique relation that I need to enforce? My ...
1
vote
1answer
331 views

SQL Server 2008 R2 - Weekly / Monthly Statistics

I'm new working with SQL Server 2008 R2 Express, and I´d like to gather some statistics every week / month for users who are connecting to this server. For instance, how many times they were ...
5
votes
1answer
216 views

SQL Server Mirroring kicks in before cluster has time to fail over

I have two clusters each with two nodes configured in active/passive; the two clusters take part in a high-availability mirroring session using a separate server as the witness. When a node fails in ...
2
votes
1answer
233 views

SSMS Object Explorer Details causes deadlock while job is running

I have a problem with one of my SQL Server jobs. I've found that while the job is running, SQL Server Management Studio locks up. It always locks up while I'm looking at tables and sprocs within the ...