Microsoft's SQL Server is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It originated from the Sybase SQL Server codebase, which is why both products use the extension of SQL called Transact-SQL (T-SQL).

learn more… | top users | synonyms (2)

2
votes
4answers
7k views

decrypt/get sql user password

I have a sql server 2005 database server. I have administrative access(sa access) however I need the password to a specific account on the server. I can't really reset the password to this account ...
5
votes
2answers
1k views

How to automatically stagger transaction log shipping to minimize bandwidth usage peaks?

The following question pertains to Microsoft SQL Server transactional log shipping (TLS). We're using SQL Server 2008 R2 SP1, although the question is probably relevant for all recent editions. ...
9
votes
1answer
2k views

Interpreting SQL Server's Showplan XML

I just rolled out a feature on my site http://sqlfiddle.com that allows users to view the raw execution plans for their queries. In the case of PostgreSQL, MySQL, and (to some extent) Oracle, looking ...
41
votes
4answers
14k views

What are Objective Business Reasons to Prefer SQL Server 2012 over 2008 R2?

My company is facing the decision whether to purchase SQL Server 2012 Denali or SQL Server 2008 R2 for a new database server. I am looking for objective reasons to choose one over the other. Our ...
8
votes
3answers
252 views

Nonclustered Index Insert

Say I have a table like this: create table SomeTable ( id int identity(1, 1) not null primary key clustered, SomeString1 varchar(50) not null, SomeString2 varchar(50) not null ) go ...
0
votes
1answer
90 views

can I copy-paste SQL Server 2005 Express on XP Pro or Vista machine and make it work without installer?

I am having installer problems on several machines trying to install SQL Server Express 2005 Express as well as later versions (but I would be happy with 2005 anyway). However, I do have one machine ...
1
vote
3answers
6k views

How should I Schedule SQL Server 2008 queries to run every month?

I need to schedule some queries to run at the beginning of every month (for monthly reports) and I read that creating a JOB in sql server 2008 was the way to go. Unfortunately, I don't have the ...
4
votes
1answer
2k views

How do query notifications detect changes in the query result?

I am working with a legacy database that has implemented query notifications against a table called ColorList. While running a server-side trace for an unrelated issue, I noticed the query SELECT ...
9
votes
2answers
3k views

Restore bak file to smaller mdf and ldf database files

I have a legacy database whose nightmarish lack of design I will not get into here, but the files on the server are (relatively) enormous. I have: MyDatabase.mdf: 24.8GB MyDatabase.ldf: 114.6GB This ...
2
votes
1answer
924 views

ODBC Connection As Clustered Resource

First step in a long process of creating a Linked Server to an Informix database on a Sql 2008 (Win 2003 x64) cluster. I was wondering how to go about creating an ODBC connection as a clustered ...
6
votes
3answers
4k views

Do you know an easy way to generate one record for each hour of the past 12 hours?

I have a report that shows the count of events for the past 12 hours, grouped by the hour. Sounds easy enough, but what I am struggling with is how to include records that cover the gaps. Here is an ...
1
vote
1answer
530 views

Execute Stored Procedure against CMS from within a SQL Server Agent job

Is it possible to execute a stored procedure (or any T-SQL) against a Central Management Server (CMS) via a SQL Agent job? The idea here is to exercise the CMS to hit all the registered instances ...
1
vote
3answers
148 views

Keeping an eye on contention

In SQL Server, I am using the following command to see blocked sessions: select * from sys.sysprocesses where blocked>0 This is super. The problem is I need to see what block sessions there ...
3
votes
3answers
4k views

SQL Server R2 and HyperThreading - Max Worker Threads and performance

SQL Im getting this error: This file is generated by Microsoft SQL Server version 10.50.2500.0 ...
10
votes
1answer
581 views

What does a SQL Server DBA need to know about Windows Server?

Analogous to my previous question What does a DBA have to know about SSAS?, which generated a really wonderful answer (thank you, @ConcernedOfTunbridgeWells!), I now ask a similiar question: What ...
22
votes
4answers
8k views

SQL Server “empty table” is slow after deleting all (12 million) records?

I have a SQL Server 2008 instance with approximately 150 columns. I have previously populated this table with approximately 12 million entries, but have since cleared the table in preparation for a ...
4
votes
1answer
395 views

Sql Server Full Text Search one table for text values in another table

Is it possible to run a full text search on an FTS-indexed column for all values in another table? Conceptually it'd look like select d.* from Docs d, Tags t where CONTAINS(d.fulltext, t.tagvalue) ...
24
votes
2answers
12k views

What does a DBA have to know about SSAS?

I've seen a lot of material covering the business aspect of SSAS, but not really much about the important aspects of administration and management. From the point of view of administering an instance ...
8
votes
1answer
286 views

Most efficient way to get stats on an entire SQL Server database

What I'm looking to do is review our databases and lock down any auto-shrink settings, as well as get a handle on which databases/tables are highly fragmented. Is there a particular script I can run ...
2
votes
1answer
77 views

Diagnose slow SQL in SQL Server

I am not a DBA so please be patient with me... Is it possible to turn on a trace on SQL Server which will tell me any SQL statement that takes longer than 2 seconds to execute, when it happened and ...
2
votes
3answers
129 views

Table size and table partitioning on a single drive server

Suppose I have a big table on a server with only one drive. The table may grow up to a half TB (hundred million rows). I think the purpose of the partitioning is mainly for maintenance purpose because ...
0
votes
2answers
4k views

Cannot get a message to go to a SQL Server Service Broker Queue

I am trying to setup a simple SQL Server Service Broker messaging setup. I am following the MS tutorials, but I cannot get the following code to work. Everything runs fine, but the message does not ...
1
vote
1answer
239 views

Is it possible in a view to reference a linked server implicitly rather than explicitly?

I'm using views and stored procedures that reference a linked server: SELECT Id, Name FROM [LinkedServer].Database.dbo.FooView I would like to hide the [LinkedServer].Database or at least the ...
2
votes
2answers
303 views

Can I move a system database from one version of SQL server to another?

We are moving our databases from one computer running SQL Server 2005 to a different machine running SQL Server 2008. I am following the steps found here, in an attempt to copy over the master ...
5
votes
4answers
13k views

When was data last inserted/updated/deleted in a table?

I have found this solution, but this information is lost everytime the SQL Server service is restarted, or in other words, it is not persistent. Is there another way I can find out when a table was ...
10
votes
1answer
705 views

Definitive list of steps for SQL Server baseline testing?

Before running a performance test / baseline for an app that uses SQL Server, I want to be able to set the instance to a "clean" state, without restarting the instance. There are steps I tend to ...
14
votes
3answers
13k views

Common Table Expression (CTE) benefits?

From msdn : Unlike a derived table, a CTE can be self-referencing and can be referenced multiple times in the same query. I'm using CTEs quite a lot, but I've never thought deeply about the ...
7
votes
2answers
8k views

What are the differences between Mirroring and Failover Clustering and when is each one recommended over the other?

What are the main differences between Mirroring and Failover Clustering? What kind of problem each one solves and in what kind of scenarios is each one recommended over the other?
14
votes
1answer
535 views

Poor SQL Server performance when management studio closed

I've noticed a strange behaviour of SQL Server 2008 r2 express: usually my query execution time is ~650ms, but if I open Management Studio and run any simple query (for example SELECT * FROM ...
1
vote
1answer
137 views

Rolling changes to production databases

We're currently using Clustering to do fail over for our SQL environment. There are two servers that use the same shared drive. The SQL database is on a shared drive. This provides OS and hardware ...
-1
votes
1answer
5k views

sql server - could not allocate space for object

I am trying to retrieve the first 1000 records of my view and am getting this error message: Msg 1105, Level 17, State 2, Line 2 Could not allocate space for object 'dbo.SORT temporary run ...
7
votes
1answer
711 views

Full-text index in partitioned table

I have a table with just over a million records with a full-text index. This table has been split in two in the past, and the data older than a certain date is moved to another table with the exact ...
5
votes
1answer
3k views

How to detach corrupt database in SQL Server

I have Sql server data files saved on external storage. I want to detach specific database. If external storage is not connected I want to drop database. Is this safe way to do that: DECLARE ...
6
votes
3answers
7k views

How to make sure that simultaneous INSERT and SELECT on one table won't make a deadlock?

I have the following table in my SQL Server 2008 database: CREATE TABLE [dbo].[SomeTable] ( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Column1] [varchar](30) NOT NULL, [Column2] [varchar](30) ...
6
votes
1answer
119 views

When you back up a database and scripts are running at the same time, at what point in time does the backup reflect?

If I run a SQL Server database backup via Management Studio and there are scripts running at the same time, does the backup reflect the point in time when the backup was started or when it ended? My ...
5
votes
2answers
2k views

Perform UNION ALL regardless of column order in the two joined tables

SELECT * INTO TABLE1 FROM Table2 UNION ALL SELECT * FROM Table3; GO I am using this query to stack two tables together into one table. These tables should have the columns in the exact same order ...
2
votes
3answers
79 views

After server move a query doesn't work anymore

I've moved an ASP+SQLServer application from an old server to a new one. The old one was a Windows 2000 server with MSDE, and the new one runs Windows 2008 with SQL 2008 Express. Everything is ok, ...
4
votes
1answer
589 views

How to change database owner for login and database created inside stored procedure?

I have a signed stored procedure that creates a new database, a new login and assigns the new user to be the owner of the new database. Well my SProc creates the new login and new database but will ...
3
votes
1answer
119 views

Trace To the Error Log

Thomas LaRock (SQL Rockstar) put up an article on how to write executed commands directly to the SQL Server Error Log without having to use Profiler (or SQL Trace). The article/video can be found ...
5
votes
1answer
11k views

Repairing corrupt SQL Server database backup?

I'm looking at a problem for someone who was backing up to a cloud-based service. Apparently the customer's server crashed while it was performing some maintenance on the cloud-based service's ...
-5
votes
1answer
2k views

SQL Server 2000 to 2008 R2

When I try to restore a database abackup from a SQL Server 2000 to 2008 R2m, I get this error: Actually, I don't quite get it. What does the error actually mean? And how can I solve it?
6
votes
3answers
780 views

Can I query stored procs in all databases with one query without dynamic sql

If I want to query all databases on a server to see if a stored procedure is present, I can combine a sp_executesql and run a cursor over a query similar to the following: SELECT 'select ' + ...
11
votes
3answers
8k views

How should I configure the RAID array of SSD drives on my SQL Server?

I'm building a SQL Server with 48 GB RAM, 1 CPU, & 8 SATA III (6GB/s) SSD drives (128 GB Crucial m4) and an LSI MegaRAID controller (SAS 9265-8i). I expect the typical work load to be mostly ...
9
votes
2answers
9k views

Table not getting created under dbo schema

When creating tables in SSMS, I've realized that if you execute the following statement: CREATE TABLE [tableName]; the table will be created under your own schema (and not dbo). So in order to ...
3
votes
2answers
3k views

Get failed SQL Server agent job?

How to get a list of failed job run last night? I only find the following powershell script. What's the SQL equivalence? dir $psPath\Jobs | % { $_.EnumHistory() } | ? { $_.RunStatus -ne 1 }
2
votes
1answer
1k views

Activity Monitor Showing Long Duration for WAITFOR

Using Activity Monitor, I am consistently seeing the following query showing an average duration of over 300 seconds: WAITFOR(RECEIVE conversation_handle, service_contract_name, message_type_name, ...
2
votes
2answers
4k views

How to lock a Row while I'm using it

I want to be able to Lock a row, select it, increment its value, and then release the lock. (without lockin the other rows, so that other connections can work with the rest of the table) I've found ...
5
votes
2answers
4k views

What server property makes TransactionScope escalating to MSDTC?

In our application we're using TransactionScope's. We're aiming to not use the MSDTC service because it's a lot slower than lightweight transactions. using (var transactionScope = new ...
1
vote
2answers
611 views

Create multiple files for each file group for table partitioning?

I am partitioning a table by date (month). The server has four drives. The partition scheme is defined as CREATE PARTITION SCHEME ByDate AS PARTITION ByDate TO ( [PRIMARY], [fg2], [fg3], [fg4], ...
0
votes
1answer
293 views

Found errors in table after executing DBCC CHECKTABLE command

I am trying to alter table to add primary key ALTER TABLE GeoCity ADD CONSTRAINT PK_GeoCity PRIMARY KEY(locId) and got this error message Msg 1750, Level 16, State 0, Line 1 then I run ...