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)

3
votes
1answer
3k views

What does Error: 17828, Severity: 20, State: 4 mean?

I've found this guy in my SQL log: "The prelogin packet used to open the connection is structurally invalid; the connection has been closed. Please contact the vendor of the client library. [CLIENT: ...
21
votes
4answers
16k views

Should dbo schema be avoided?

When it comes to the dbo schema: Is it a best practice to avoid using the dbo schema when creating database objects? Why should the dbo schema be avoided or should it? Which database user should own ...
2
votes
2answers
118 views

SQL index with additional includes

In an effort to be more efficient when creating a new index, if there is already an index with the same index keys, but it simply needs additional include columns, is it better to create a second ...
11
votes
6answers
8k views

Suddenly Slow Execution Plan for Stored Proc

I'm trying to understand an issue we're having with SQL Server 2000. We are a moderately transactional website and we have a stored proc called sp_GetCurrentTransactions which accepts a customerID, ...
5
votes
2answers
464 views

If a query triggers a statistics update and times out are the statistics still updated?

I have a fulltext query which is usually very fast but may time out when it causes a statistics update since statistics updating is very slow on this database. Usually the query "recovers" to normal ...
0
votes
1answer
147 views

Set timeout expiration in ms sql 7

I'm trying to perform a query in a transactional database that was used for more than 3 years. But it always says timeout expired after running for about 30 seconds when I try to run this query: ...
12
votes
1answer
3k views

Why is Clustered Index Scan Number of Executions so high?

I have two similar queries that generate the same query plan, except that one query plan executes a Clustered Index Scan 1316 times, while the other executes it 1 time. The only difference between ...
1
vote
1answer
1k views

Can't run query using “localhost\sqlexpress”

I am trying dynamically build an SQL Statement that includes linked server. That works. When I use "localhost" to reference the current local machine SQL Server, that doesn't work. For example: ...
4
votes
2answers
1k views

SSAS queries time out when Windows File System Cache drops

We have a SQL 2008 Analysis Services instance on Windows 2003 that is experiencing near-daily performance issues (query timeouts) during peak activity. A second identical instance queried from the ...
3
votes
3answers
2k views

Unable to get DBMail working on SQL Server 2005

I have SQL Server 2005 SP3 (4053) running on a Windows Server 2003 R2 virtual machine. When trying to send a test dbmail message, either from the SSMS GUI or using sp_send_dbmail, I get the ...
3
votes
1answer
274 views

Does blocking always mean open transaction?

This may seem a bit dull question but does blocking always mean that there is open transaction and that may cause transaction log grow to infinity because open transaction prevents log truncation ...
6
votes
1answer
351 views

What 'resets' the transaction log

My question might sound rather strange but I'm not really a SQL expert and I can't find the answer.. I'm trying to create a backup plan which creates a full backup twice a day. A differential back-up ...
0
votes
1answer
921 views

Getting the metadata about a Query and a Stored procedure in SQL Server

I would like to get all the names of the columns in a given query [SQL Textual Query] and also the columns that are in the SELECT clause in a Stored Procedure. Is there any ways other than using ...
1
vote
1answer
403 views

How to take Snapshot of Restoring Database

I have set up log shipping with my database to make a backup. The backup copy of the database is in a status called '(Restoring...)'. I understand this is to be expected? Is there a good way I can ...
2
votes
2answers
505 views

How do you restore (or check) only the extended properties in a MS SQL Server .Bak file?

We store the version number of our DBs as an extended property. As part of the automated build process, I want to be able to check that the "empty" DB that is part of the build set matches the version ...
2
votes
2answers
3k views

How To Restore A Replicated Database

I am replicating our live database using transaction replication. This is basically to have a backup copy of our database in the case of server failure. The replicated database is read only, so I ...
2
votes
1answer
92 views

Data Extract and submit across the network

I've been given a somewhat vague requirement regarding a data extract process which I need some help with. I'm fairly new to database warehousing etc. but I will try to explain everything relevant. ...
4
votes
2answers
2k views

How do you use MAXDOP in a View?

I have several views that are used to export data from SQL-Server into .csv files. They are all executed via SSIS packages. Our DBA has decided to set the "Max Degree of Parallelism" to 1 and told me ...
3
votes
1answer
652 views

SQL Globalization - DateTimeOffset

What is the recommended best practice when it comes to storing date/time for an application that needs to support multiple timezones? Which is best ? Use the SQL DateTime data type and insert ...
2
votes
1answer
1k views

How often should I run integrity and consistency checks on SQL Server 2008?

Before updates of our application, I run some checks on the database like CheckAllocations and CheckCatalog, so I know the database is in good shape before the update scripts get executed. What is ...
4
votes
2answers
5k views

Sort by match of LIKE

I wondering how I can implement SQL to get results sorted by best match of a like predicate. I have 100K articles in the database and when user call some items by part of name. I want to show the ...
0
votes
1answer
2k views

SQL Server 2012 Installation Error

I been trying to install SQL Server 2012 on Windows 7 SP1 32 bit. Logged in as Administrator and launched setup. Everything installs fine but SQL Server DB Services fails with following error ...
12
votes
6answers
5k views

Reasons for disabling statistics auto update?

I just learned that a client company I work for has decided to keep the auto update statistics options off for some of their SQL Servers, and the DBAs manually troubleshooting performance issues when ...
2
votes
0answers
275 views

MS-SQL index not using all the available columns as seek predicates [duplicate]

I have a SQL Server query on a large table (>17 million rows) that sometimes does not populate all the predicates before performing an index seek, which results in not filtering out enough rows and ...
1
vote
2answers
9k views

Connect to SQL Server Management Studio over VPN (Hamachi)

I just got my Hamachi VPN set up. For anyone familiar with Hamachi, I have it set up as a gateway so I'm part of the network when I'm away. Almost everything seems to be working perfectly. I can ...
7
votes
2answers
4k views

Best block/stripe size for log volume?

I know the common recommendation for the data volume in SQL Server is to use 64 KB blocks/stripes, since the I/O is typically done by entire extents. I can't find any good information regarding log ...
1
vote
2answers
157 views

Restore backup in order to write datafile sequentially in disk

I have just come to a new company and we have one database which was created with standard initial size and autogrowth parameters for data and log files (1 MB autogrowth for data / 10% for log). The ...
1
vote
1answer
772 views

SQL Server Database Keeps Semi-Detaching Itself

Forgive me if I am not using all the proper terms but I have databases that will detach themselves from SQL Server. In SQL Server Management Studio the plus sign will be missing next to the database, ...
4
votes
3answers
672 views

Most performant SQL query needed

I'm storing documents with fields that are set in a DataSource table. The document is written to the database as follows: Document table (ID, DataSourceID) Document fields (DocumentID, ...
3
votes
1answer
370 views

How Commit works in a transactional push replication with updatable subscribers

I want to know if in a transactional push replication with updatable subscribers, a commit is only done when all subscribers have succeeded to make it, or if it only guarantees the correct commit in ...
2
votes
1answer
275 views

Dropping then adding a table to a subscription with Identity option Not for Replication causes errors

We have a Transactional Replication environment that was initialised from a backup that replicates the data for several hundred tables. When a table is altered, say a new column added, I have created ...
2
votes
1answer
2k views

What are the names of SQL Server database statuses 24, 1024 and 65544?

using the following query: SELECT Name, Status FROM dbo.sysdatabases WHERE name IN ( 'db_name' ) I get in some cases status = 24, other times 1024 and other times 65544 I see that even when status ...
7
votes
1answer
224 views

DBCC TRACEON with the global flag

In the question Need Help Troubleshooting Sql Server 2005 Deadlock Scenario there was a suggestion of using DBCC TRACEON (1204, -1) to trace deadlocks globally. When reading about this command in BOL ...
1
vote
2answers
903 views

SQL Server AlwaysOn Failover Transparency

This is using RC0. I have set up a SQL Server 2012 AlwaysOn (or more accurately, highly-likely-but-not-always-on) Availability Group. I take the Primary offline. The Secondary takes up to 25 ...
2
votes
1answer
362 views

Accessing Service Broker from Different Databases

In my Application we have a lot of databases nearly 100 dbs. We are planning to use Service Broker for calling a Stored Proc Async. Instead of running Service Broker on all the Databases, Is it ...
12
votes
5answers
1k views

What are efficient ways to deal with database schemas that are shared between code branches?

Working on a project with multiple branches, where each branch is eventually merged back to the main branch, and in essence is isolated in order to develop a new feature. The database, which is MS ...
2
votes
3answers
1k views

Loading a FACT table per day

I have a database with 13 billion rows, per day I have around 20-30 mio rows. On top of this I have one cube, one of its dimensions is DateTime that goes down to milliseconds. To load the fact table I ...
3
votes
2answers
167 views

Failing SQL Job

I've been passed a sql server scheduled job that's recently started failing. It basically runs a stored proc that runs a query, the query joins a bunch of tables together and populates a derived ...
8
votes
2answers
2k views

Shared Lock issued on IsolationLevel.ReadUncommitted

I read that if I use IsolationLevel.ReadUncommitted, the query should not issue any locks. However, when I tested this, I saw the following lock: Resource_Type: HOBT Request_Mode: S (Shared) ...
5
votes
3answers
3k views

Is there a way to see the access log of a table?

I am using MS SQL Server 2008. I have a table in a database, in which records are being inserted and deleted. E.g. Initially the table is empty. A Java program (probably) inserts few records in it. ...
3
votes
3answers
3k views

SQL table design for primary keys (best practice)

I have a User table that contains the following fields ID (Auto-generated GUID) UserName Password FirstName LastName Email AddressID (GUID) This is linked to the table Address (1-1 relation) which ...
0
votes
1answer
842 views

Make SQL Server Agent retry failed script with Try/Catch

I have a script that has a try catch in it so that if it fails I can roll back the transaction. It runs on a job scheduled through SQL Server Agent. But when it fails SQL Server Agent does not see ...
6
votes
3answers
3k views

Can you prevent more than X number of rows being updated in SQL Server?

Is there a way to configure SQL Server to limit the number of rows than an update statement can modify? Say I wanted the limit to be 30,000 rows and someone fired an update that would modify 45,000 ...
1
vote
1answer
759 views

How to setup daily SQL server export to csv text file?

We are exporting 100,000+ rows from a SQL Server 2005 DB to a text file. We have a web script setup to read all rows and then write the text file and it takes over 5 minutes to complete that script. ...
1
vote
1answer
14k views

Working example of OPENDATASOURCE command using SQL Authentication

I need to run some ad-hoc queries on several hundred servers that are not part of a domain. Each server has a low-privilege SQL user account that has read-only access to a few tables of interest. My ...
8
votes
4answers
4k views

SQL Server Partitioning - what to use for partition key?

I've never worked with SQL Server partitioning but I currently faced with designing a database for which the volumes probably warrant it. The system is for coupons. The coupons are to be issued ...
1
vote
2answers
2k views

How can I check the status of transactional replication?

How can I check if there are commands waiting for being executed in the subscribers and find if there is any error occurring in my publication. I want to be able to do this programmatically so the ...
1
vote
2answers
1k views

Any security related reasons to prefer Windows Authentication over Sql Server Authentication?

This is a rather short question: When using Microsoft SQL Server (version 2005 and newer), are there any security related reasons to prefer Windows Authentication over SQL Server Authentication? ...
8
votes
5answers
1k views

Over use/correct use of schemas?

Having asked This question on Stackoverflow, I wondered where what I have done is correct/best practise. Basically, every object that I create is going into a schema with the schema name reflecting a ...
4
votes
4answers
304 views

SQL Server Optimization/Configuration for Inflexible Application

I'm responsible for overseeing an application which uses SQL Server as its backend storage solution. Unfortunately, the application has no concept of how a RDBMS should be utilized and seems to use it ...