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)

6
votes
1answer
83 views

Is there a performance hit by breaking out tables into different schemas in SQL Server?

Is there any kind of performance hit when querying by placing tables in different schemas in SQL Server. For instance if I had 2 tables, Table1 and Table2, and put Table1 into the test schema and ...
8
votes
5answers
1k views

Using IF in T-SQL weakens or breaks execution plan caching?

It has been suggested to me that the use of IF statements in t-SQL batches is detrimental to performance. I'm trying to find some confirmation or validate this assertion. I'm using SQL Server 2005 ...
5
votes
3answers
7k views

Howto use Windows Authentication with SQL Server 2008 Express on a workgroup network?

I have two computers running SQL Server 2008 Express: c01 and c02, I setup both for remote connection using windows authentication. Worked fine for c02 but not for c01. This is the error message I'm ...
2
votes
1answer
60 views

Sql Server Backup to URL (Azure) ERROR

I'm trying to take advantage of the new backup to url function in SQL Server. I have created a valid cert and tried a simple backup, but I get the same error every time no matter what I try. I have ...
2
votes
3answers
3k views

Restore SQL Server database using Windows Powershell 3.0

I'm trying to restore a SQL Server database with a PowerShell script, but I'm having problems. Here is the error I'm getting: Exception calling "SqlRestore" with "1" argument(s): "Restore failed ...
33
votes
6answers
28k views

What are the main causes of deadlocks and can they be prevented?

Recently one of our ASP.NET applications displayed a database deadlock error and I was requested to check and fix the error. I managed to find the cause of the deadlock was a stored procedure that was ...
14
votes
1answer
3k views

How to get the MAX row

In SQL Server I've always found it a pain to get the max rows for a dataset, I'm looking for a list of the methods to retrieve the max rows with some guidance on performance and maintainability. ...
0
votes
2answers
65 views

SQL Server 2012 Very Slow to Consume Memory

I have a bit of a conundrum. I recently upgraded a ~20gb database from Window Server 2008 R2 || SQL Server 2008 R2 to Window Server 2012 || SQL Server 2012. The previous server had 32gb of memory, ...
3
votes
1answer
57 views

How to identify unused databases on my sql server

I am looking for the best practices or analysis someone would have followed to identify the unused or inactive databases on my SQL Server. I went through many articles, which say possibly to go for ...
4
votes
1answer
28 views

How do I determine the spid of the session that is making a query on a linked server?

I have a session running on a SQL Server instance that is blocking other sessions (holding on to a lock without releasing it). Querying sys.sysprocesses yielded the hostname of a different SQL Server ...
4
votes
4answers
82 views

Conversion of a varchar data type to a datetime data type resulted in an out-of-range value

I am trying to run a simple query to get all rows created in November: SELECT COUNT(*) FROM dbo.profile WHERE [Created] BETWEEN '2014-11-01 00:00:00.000' AND '2014-11-30 23:59:59.997'; SMSS ...
0
votes
2answers
3k views

Problems during installation with Database Engine Service

Overall summary: Final result: Failed: see details below Exit code (Decimal): -2061893606 Start time: 2014-07-04 13:40:51 End time: ...
2
votes
0answers
27 views

Exclude a User From an Audit

I need to set up a SQL Server audit to capture all database activity for all logins except one - the login our application runs under. In this case the login I want to exclude is CPSDOM\cpointedb. In ...
0
votes
1answer
728 views

SQL Server: subscriber as publisher and hierarchical replication

In Oracle Streams one way replication from one DB to another is a basic block for many replication topologies (N-way, hierarchical, combined and so on), and changes could be captured and applied for ...
8
votes
1answer
63 views

Visualizing SQL Server Extended Events data

Lately I've been exploring using Extended Events in SQL Server to help me benchmark and optimize various queries. So far, to view the event data I have been using the "Watch Live Data" feature in ...
3
votes
1answer
204 views

Issue shrinking dev sql server DB's log file

I have a development db that's running on sql 2014 in 2012 compatibility that I'm having an issue with trying to shrink the log file. The mdf is 60+gb and the log is 80+gb but since it's dev like ...
12
votes
3answers
329 views
+500

Retrieving n rows per group

I often need to select a number of rows from each group in a result set. For example, I might want to list the 'n' highest or lowest recent order values per customer. In more complex cases, the ...
-4
votes
2answers
56 views

Microsoft recommends using Rowversion over timestamp , but i can not find “rowversion” data type inside my sql server 2008 R2 [on hold]

MS on this link http://msdn.microsoft.com/en-us/library/ms182776.aspx mentioned that we should use rowversion data type over Timestamps. Now inside my sql server 2008 R2 I want to create a column with ...
2
votes
1answer
71 views

XML Whitespaces/Unwanted Characters

Could anyone help on how to remove white spaces from an XML file? I used the following code that i got from Mikael Eriksson on Stack Exchange to extract the site id: cast(msg as ...
12
votes
2answers
52 views

In SQL Server, can I guarantee an order without an explicit ORDER BY clause when an index seek is forced on a table with only a clustered index?

Update 2014-12-18 With the overwhelming response to the main question being "No", the more interesting responses have focused on part 2, how to solve the performance puzzle with an explicit ORDER ...
1
vote
0answers
24 views

SQL Native backup MIRROR TO performance

We are moving to SQL Server 2014 Expensive Edition Q1 next year. Right now we are on SQL Server 2005 Standard Edition, so we don't have access to the oh-so-wonderful MIRROR TO option for our backups ...
0
votes
1answer
330 views

Does SQL Server require SSLv3?

We have a Windows 2008 R2 server running SQL 2012 Express RTM (11.0.2100.60). All three protocols (shared memory, named pipes, TCP/IP) are enabled for the server and both 32-bit and 64-bit clients. ...
0
votes
0answers
35 views

How to dynamically alias subquery column [on hold]

I found this How can I dynamically alias columns to be very useful however is there anyway around columns created from subquery Such as SELECT COL1 AS "Column1" (SELECT TOP 1 (COL2) FROM ...
0
votes
2answers
37 views

Suspended query causing high CPU usage

Environment detail: SQL Server 2008 R2. I have applications running on JBoss that access the DB using JDBC driver. Issue: My online DB server was experiencing high CPU usage. Using the ...
0
votes
0answers
13 views

What are the considerations for relocating BLOB storage

I'm just wondering if there are any considerations for relocating a BLOB storage to free up some space in SQL Server 2008 R2
0
votes
0answers
19 views

BLOB storage relocation

Hi all is there any considerations for relocating a BLOB storage to free up some space on SQL server 2012 R2? Also what are the processes that should be followed?
0
votes
1answer
13 views

Dynamic Condition Creation function

I have a function which needs to create a dynamic where clause by reading the columns from the temporary table . CREATE FUNCTION [dbo].[GetWhereClause] ( @TempTableName nvarchar(600) ) RETURNS ...
0
votes
0answers
10 views

Shrinking old partitions

I have a large partitioned time series table where each partition is stored in it's own file. Since it's time series based partitioning divided by week and I'm only storing data that is new I have ...
0
votes
1answer
26 views

How to delete row from table later than date?

I have a simple table: MyTable: -Id int primary key -Name varchar(MAX) -Deleted bit Now i want delete rows created later that 15.12.2014. But how can you see i don't have a any date columns in my ...
1
vote
1answer
33 views

How do I get the count for time periods?

I have a table with the following columns. [ComputerGroupid], [Computerid], [Userid], [loginTime], [logoffTime] And my requirement is to get the table with the below information ...
2
votes
1answer
208 views

Database design for a table with both bulk insert and single row insert

I have to design a table where records will be inserted in two ways. Bulk insert from a batch process from a delimited text file between 2 - 3 million rows in a short burst. Later the same records ...
12
votes
2answers
115 views

Excessive sort memory grant

Why is this simple query granted so much memory? -- Demo table CREATE TABLE dbo.Test ( TID integer IDENTITY NOT NULL, FilterMe integer NOT NULL, SortMe integer NOT NULL, Unused ...
1
vote
1answer
54 views

How to retreive deleted records in a trigger on a table with composite primary key

I am trying to optimize a trigger on a table in a database from a 3rd party. I am not allowed to change or add any columns to the schema. The table has a composite primary key, one column is an ...
0
votes
0answers
22 views

Query plan reads vs statistics io reads

I have a very strange problem. When I run a query with SET STATISTICS IO ON, it shows that I had a total of 183 reads. But when I look at the query plan dmv it shows I did 555,132 reads. I cleared the ...
0
votes
0answers
46 views

SQL Server 2008 R2: After Insert Trigger and Query returning unexpected results for a split second

I am having trouble with an After Insert trigger and a query running right afterwards. The query goes and finds the most current record in each table by using OUTER APPLY with a table-valued ...
0
votes
1answer
13 views

The process is running and is waiting for a response from the server - transactional replication

I could not yet figure it out why one of my transaction replication subscription is constantly coming out with the following annoying message: The process is running and is waiting for a response ...
1
vote
2answers
345 views

SQL Server 2005 upgrade service pack via command line

I have been wracking my brain over upgrading sql server 2005 to sql server 2005 sp4. I have a script for installing new instances of sql servers for all versions and they all work wonderfully. Problem ...
3
votes
3answers
1k views

SQL Server dates - can I get date and hour?

In SQL Server, can I do the equivalent of to_char(date_field, 'YYYY-MM-DD:HH24') in Oracle to get 2012-01-30:23?
3
votes
2answers
369 views

SQL server query is slow *without* including execution plan

I have just set up fresh installation of SQL Server 2012 on a new server and I'm experiencing very strange performance problems. Long story short, for some reason not including execution plan makes my ...
0
votes
0answers
20 views

Cannot add “rowversion” data type in sql server 2008 r2 management studio, or even to modify existing column data type [duplicate]

I want to create a column with Rowversion data type, but inside my SQL Server 2008 R2 Management Studio, I cannot find such a data type: Also when I tried altering existing column named timestamp ...
4
votes
3answers
433 views

Is it advisable to use a temp table when the stored procedure could be run simultaneously by different users?

I am working on a stored procedure that retrieves the objectGUID from active directory. I am storing the result in a temp table and then returning the value in an output parameter for use with other ...
1
vote
1answer
192 views

Deadlock occurring on database, SQL Server 2008R2

Last few days I had major problems with my production site, turns out deadlock occurred, every half an hour maybe 50-60 of them. To do a quick fix in order to keep the site running I set : ...
0
votes
0answers
23 views

Remove dupes from joins

I am trying to get all accounts with duplicate end dates. I need info from four tables that only have the FK LDC_ACCT_ID in common. When i join the tables i get tons of dupes. I understand why but I ...
0
votes
1answer
36 views

Breaking a big insert query into smaller ones

I have the below INSERT query. It tries to insert over 50,000 rows and it fails because of logging. Is there a good way of splitting a query like this into batches of about 1000 or so with COMMIT ...
3
votes
3answers
68 views

Help with SQL Query to XML output

I have the following query: SELECT [ID] AS [NewID] , ( CASE WHEN LEN([MiddleName]) > 0 THEN [LastName] + ', ' + [FirstName] + ' ' + LEFT([MiddleName],1) + '.' ...
0
votes
0answers
27 views

Equivalent data types in Oracle database for Sql server 2008’s uniqueidentifier and timestamp

I am working on an Sql server 2008 R2, and I have data types which is specific for Sql server including:- - UniqueIdentifier - Timestamp. Now I want to deploy my asp.net mvc-5 web application on ...
1
vote
1answer
47 views

Computed column 'IsWeekend' in table <table_name> cannot be persisted because the column is non-deterministic

I'm in the process of tuning a query in SQL Server 2012 that is spilling to tempdb due to an incorrect cardinality estimation when using the DATENAME() function on a column to check if the data is ...
3
votes
2answers
146 views

Change Data Types large Live table

I have a table in SQL Server 2008 R2 with close to a billion rows with Composit PK Column. I want to change the Datatype of Columns from Date to Datetime. Two times ALTER TABLE zzz ALTER COLUMN yyy ...
7
votes
2answers
20k views

SQL server databases stuck in restoring state

I have a Sharepoint server. I guess our network administrator has miss configured his back up tool (I guess he uses Symantec backup exec) and now some of my databases are stuck in restoring state! ...
4
votes
2answers
55 views

Using Database Engine Tuning Advisor in production

I have a SQL Server 2008R2 OLTP database which is experiencing performance issues during work hours. I would like to run Database Engine Tuning Advisor on this instance but I don't know how it will ...