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)

16
votes
3answers
4k views

Painless way to create a clustered index on a huge table?

So we have a customer site that is complaining about some seriously slow performance. I took one look and it's obvious that the problem is because Somebody Else (grrrr) designed a table holding some ...
1
vote
2answers
2k views

Installing SQL Server Express instance so common users can access

I need to install a SQL Server Express instance (as an admin) which can be later on read and modified by regular users. I run into http://msdn.microsoft.com/en-us/library/ms254504.aspx, and I'm ...
0
votes
1answer
419 views

enable agent XPs

I am trying to run the following script on SQL 2000: sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'ave enabled' 1; GO RECONFIGURE; GO sp_configure 'Agent XPs', 1; GO ...
3
votes
2answers
246 views

Database size increases after creating a partition

I have just partitioned an existing table. The database size was 5GB with 14 million records prior to the partition operation. After the partition operation moved rows to the new FileGroup, I ...
1
vote
1answer
1k views

SQL Server 2008 R2 Most Efficient Full Text Search Field Type

In SQL Server 2008 R2, what is the most efficient column type to store data enabling full text search? I can currently see two options, nvarchar and varbinary. Which one performs better and why? ...
1
vote
1answer
531 views

Optimization: Delete with Top and minimize the where clause date range

I have a delete statement that get run repetitive until all the data are removed. Delete TOP (1000) From Log Where CreationDate < '2011-Dec-31' AND pKey NOT IN (...) I am considering of ...
6
votes
3answers
7k views

What is the best and easiest way to turn off SQL Server when not in use?

Situation: developer workstations that typically just use the client tools to connect to other non-local sql servers. However, there are rare times that having the full version of sql server to do ...
4
votes
2answers
657 views

how to get unique records

Table structure CREATE TABLE [dbo].[Order Details2]( [OrderID] [int] NOT NULL, [ProductID] [int] NOT NULL, [UnitPrice] [money] NOT NULL DEFAULT (0), [Quantity] [smallint] NOT NULL ...
4
votes
2answers
7k views

In a trigger, how to check if no fields have changed?

If we receive an update statement that does not check if the value has changed in the where clause, what are the different ways to ignore that update inside a trigger? I know we can do a comparison ...
0
votes
1answer
152 views

Columns are added in wrong order

I have a encountered strange behaviour adding columns to an existing table. I run those scripts using osql several instances. Let Table a_table have initially three columns A_col, B_col and C_col. ...
1
vote
1answer
2k views

Heterogeneous queries error using stored procedure

Stored procedure ALTER PROCEDURE Proc_DayShift AS insert into #Punching_History SELECT * FROM SERVER2.MARS.DBO.TABLE1 GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO SET ANSI_WARNINGS OFF ...
0
votes
3answers
13k views

How to add linked server SQL Server 2008 R2

I have two SQL Server 2008 located in different cities. I have physical access to one of them and I can exec SQL Server Management Studio there. For second server I have following parameters: ...
1
vote
1answer
693 views

how to transfer data from table to table

I have two tables Table1, Table2. From Table1 want to transfer data to Table2. Suppose I have the following query: Select * from Table1 where UserID between 5 and 10 I want to store above ...
0
votes
2answers
51 views

Failure to log in using just the server name

I have more than one PC connected by LAN that I access from Server Management Studio. When I try to connect with the DB server, if I place the server IP instead of the server name in the serverName ...
2
votes
1answer
499 views

How to get server event notification

I'm just getting into sql-server, so forgive me if this is a basic question. I'm building an application using .NET 4.0 and VS 2010 and ms-server2008. For my application I need to detect the server ...
0
votes
1answer
138 views

Help me to better design my query so I can gain more performance

I need to find so called first entry in database for items regarding their partners. I wrote query and it is giving me correct results but it sucks with performances. I suspect that I have missed ...
4
votes
2answers
1k views

How can I speed up a query that orders by a calculated field?

I will try and give an example - this is not my table structure - I'm simply trying to outline the issue in order to find a solution... Person Id, Name BrothersNames Id, Name SistersNames Id, Name ...
7
votes
3answers
7k views

Executing Stored Procedure that accesses another SQL instance

I apologize if this question repeats another already asked. I have searched for hours and have not found one that fits my situation. Desired Outcome A user using SQL authentication has execute ...
0
votes
2answers
519 views

SQL Server 2005: Job scheduled every 4 hrs, but sp_help_jobactivity shows unexpected value for next_scheduled_run_date

I have done a lot with sql and jobs, and this is throwing me off. My job is scheduled as shown below. I can run the job interactively from SSMS by starting the job, it runs, all is well. It is ...
2
votes
3answers
2k views

SQL Server Max number of Times a table can be referenced as a foreign key?

Is there any maximum on the number of times a single table can be referenced in a SQL Server database via foreign key? IE Table A A_ID Table B ~ B_ID, A_ID Table C ~ C_ID, A_ID Table D ~ D_ID, ...
6
votes
2answers
1k views

securely exposing sql server 2008 for windows authentication

My company wants to have approximately 100 of their sales people (distributed around the country) to be able to run stored procedures from excel and return the data onto the spreadsheet. We have sql ...
18
votes
1answer
12k views

SLEEP_TASK Wait Type in SQL Server - What does it indicate?

I haven't seen the SLEEP_TASK wait type before, and today I seem to be getting a ton of them. I'm not the official DBA, just a SQL Server developer who knows some DBA stuff. We upgraded our servers ...
8
votes
3answers
2k views

SQL Server - Multiple running totals

I've got a base table with transactions and I need to create a table with running totals. I need them to be per account and and also have a few running totals for each account (depending on the ...
2
votes
1answer
334 views

Immediate e-mail alerting for error 229 (permission denied)

For a few reasons, I'd like to have all permission denied errors (number 229) emailed to me. Checking master.sys.messages shows that is_event_logged for this error is 0. Thus that rules out using SQL ...
5
votes
3answers
1k views

SQL Server making arithmetic abort enabled

I am using SQL Server 2008. In my stored procedures, I often have to call for XML data type, functions (like split). Is it possible to permanently enable arithmentic abort for a database? I know it ...
1
vote
1answer
611 views

Insert 4 tinyint values into varbinary(4)

I'm working on a function to convert the string representation of an IP into its varbinary(4/16) form. Right now, I have this: @stringIP = '192.168.0.3' select CAST(PARSENAME(@stringIP, 4) as ...
4
votes
2answers
1k views

Scrubbing Names via SQL Query/Batch

We have sensitive information (names of people) and we're looking to put into place a script to "scrub" of the names. Has anybody come up with a good algorithm to do this, something other than just ...
3
votes
2answers
958 views

How do I replicate SQL Server index INCLUDE and STATISTICS functionality on PostgreSQL?

I'm working on a project that must support two database engines; SQL Server and PostgreSQL. We are using NHibernate as the ORM. We are running into performance issues with certain queries. Using ...
5
votes
4answers
3k views

T-SQL INNER JOIN Optimisation

Well, I really have read so many articles, used different techniques and done some random things to do this. My problem was that a have big tables (over one million rows) and some small (with few ...
2
votes
1answer
826 views

Why use custom CLR aggregate functions for string concatenation and geometry unions in SQL Server?

I often need to do string concatenation or geometry unions over a column in SQL Server 2008 and I'm aware that you can write custom aggregate functions in .NET and register them with SQL Server to do ...
2
votes
2answers
1k views

SQL Server: Do Statistics Updates cause query plans to be flushed? Should they?

I've found that a big, nasty data-extraction query that runs daily needs updated stats to avoid making horrible query plans based on incorrect rowcount estimates (let's not worry about whether or not ...
2
votes
2answers
916 views

SQL Job in idle state

A created a new SQL Job in SQl Server Agent. I followed the steps mentioned in the article http://msdn.microsoft.com/en-us/library/ms187910.aspx Still it is in idle state. PLease note that the ...
1
vote
2answers
247 views

How to get the free temporary memory available in a server

How to get the free temporary memory available in a server For example:- I am running one SSIS package to upload data to tables. First it will move all the data to temporary table and then it will ...
3
votes
1answer
139 views

should we replace some non-clustered indexes with clustered indexes

We have some data saved for reporting each of our tables currently has a unique id column that has an auto generated clustered index on the pk and a non-clustered index for the fk. I am thinking that ...
2
votes
2answers
314 views

Validate and Verify Data After SAN Migration

We are preparing to migrate to a new SAN and I have been tasked with verifying/validating data after migrating a server. Other than the DBCC commands that would tell me about data integrity, and ...
1
vote
2answers
76 views

SQL Server 2008 error when changing cores

I have a virtual machine (virtualbox) with Windows Server 2003 and SQL Server 2008, running with 4 cores. I wanted to use 6, but when i changed the machine configuration, for some reason SQL Server ...
4
votes
1answer
770 views

setup transaction replication in cross domain

I'm trying to setup transaction replication between two domains under the same active directory. The publisher server is in a DR site domain and the remote distribution server is in the main site ...
11
votes
2answers
3k views

SQL Server VARCHAR Column Width

Searching around the web, I have found conflicting advice on whether there is a performance impact when specifying overly-wide VARCHAR columns, e.g. VARCHAR(255) when VARCHAR(30) will probably do. I ...
7
votes
1answer
327 views

Could Stack Overflow run on SQL Server Web Edition?

I am starting a new web venture that may need to scale to a high number of users. I am confident with the SPLA licencing for SQL Server Web edition, but want to know if I will need to factor in ...
1
vote
4answers
120 views

copy ldf from one server to another

I keep getting "file is open in another program" when i try to copy LDFs from one production to dev. Is there another way to copy these ldfs to dev server?
4
votes
1answer
2k views

SSIS how to parse column with erratic data

I have a question on how to parse out a column and hoping a SSIS/Database guru can help out :) Here is the problem. I have a column saved as a string/varchar format in SQL Server, and need to parse ...
3
votes
2answers
4k views

Can someone explain why select with nolock will query a potion of updated data?

I was reading the answer from here (from stackoverflow, I think should ask in here) NOLOCK means placing no locks at all. Your query may returns portions of data as of before UPDATE and ...
3
votes
1answer
384 views

Shrinking log file

Some of the sql log files (idf) are hugh like 5gb. Found a article (http://extended64.com/blogs/rhoffman/archive/2009/06/11/shrink-sql-server-2008-database-log-file-script.aspx) but not sure why he ...
0
votes
1answer
298 views

Shrinking log file [duplicate]

Possible Duplicate: Shrinking log file Some of the sql log files (idf) are hugh like 5gb. Found a article ...
1
vote
2answers
149 views

xSQL trace file error

I am trying to use this programme that goes by the name xSQL Profiler but the problem is that it keeps giving me a error where it says: Trace mietrak did not start. Please check if the Trace File ...
2
votes
1answer
260 views

SQL Server Cluster Failover Making DB Inconsistency Error

I encountered the following DB tables inconsistency error whenever I do a cluster 'move' over from Server-A to Server-B and then do a DBCC CHECKDB on the database in Server-B: SQL Server detected ...
3
votes
1answer
872 views

Rebuild or Reorganize indexes based on fragmentation

I am using an Index Defrag Script, which provides a nice way to rebuid or reorganize indexes based on fragmentation percentages. I like to rebuild my database indexes if their fragmentation is over ...
15
votes
9answers
2k views

Version control for database objects

The database our developers are working on is too large (have a lot of database objects). We have to control db objects changes (change management). Our company cannot have a person who would be ...
0
votes
3answers
42 views

helping hand for sql server resources

I'm just getting into SQL-SERVER, so forgive me if this is a basic question. I need help, recently work on database programming, For my query development, to understand complex query, to can ...
2
votes
2answers
2k views

SET LOCK_TIMEOUT, is it session or statement based?

For what period does the LOCK_TIMEOUT LAST? I do a "SET LOCK_TIMEOUT 10" and a "SELECT @@LOCK_TIMEOUT" in one command after a login and get 10 returned. Immediately after this I do a "SELECT ...