This tag is for SQL Server 2008, major build version 10.00.xxxx.

learn more… | top users | synonyms (1)

2
votes
3answers
2k views

Reference a newly created computed column in the same query where we create it

SELECT (SUBSTRING(Column1,1,3)) AS ComputedColumn WHERE ComputedColumn !="dec" INTO Table2 FROM Table1; This is an example where I have a computed column (which is essentially created by using an ...
0
votes
3answers
56 views

How to enable windows authentication on server that is not part of domain

We have an SQL server instance running on a standalone server (not part of the organizations domain network). Is there any way that we can use windows authentication to logon to sql server without ...
5
votes
3answers
1k views

Should order of column in where clause be same as the index order?

I was reading this use-the-index-luke.com which explains in detail how indexes work. One of the things this person has re-iterated that the order of indexes matter a lot and to make the query fast the ...
0
votes
0answers
48 views

SQLCMD.exe in SQL Server 2012 does not give real-time output logging [closed]

I'm running a long-running stored procedure using sqlcmd.exe for automation purposes. However, I observed that in SQL Server 2012, sqlcmd.exe does not produce real-time logging. It displays only when ...
5
votes
1answer
204 views

What is a non-clustered index scan

I know what table scan, clustered index scan and index seek is but my google skills let me down to find a precise explanation into non clustered index scans. Why and when a query uses a non clustered ...
6
votes
2answers
1k views

What are the possible causes for sp_reset_connection taking a long time to execute?

Why would the sp_reset_connection system stored procedure be taking longer than a few milliseconds to execute, as viewed through SQL Server Profiler? I took a simple trace from a production system ...
5
votes
3answers
286 views

Corrupted mdf file causing the backup job to fail

We have ran into a problem with one of our SQL server 2008 databases. It appears that something is corrupted in its datafile and this has caused our daily DB backup jobs to fail. The last successful ...
1
vote
1answer
93 views

Oracle OLEDB Connections hang in SQL Server: Can I restart Instance?

There is a killed/rolled back query on this instance that was originally attempting to execute a SELECT on a remote Oracle Server via OLEDB. This query was running for over two days before it finally ...
3
votes
1answer
47 views

How do you calculate the CPU Affinity Bitmap?

I am trying to calculate the bitmap for my 32-core server. I want my instance to use cores 30 and 31. I know that CPU 0 gets assigned a value of 1, CPU 1 gets assigned a value of 2, CPU 3 gets ...
3
votes
4answers
7k views

Scriptable command line access to SQL-Server from linux

Does anyone know of a ready made1 command line tool that would allow me to connect from a linux client to a sql-server? I want to be able to run arbitrary queries, but most of the time I want to be ...
2
votes
0answers
46 views

SQL Server migration from 2005/2008 to 2012 [duplicate]

We need to upgrade two SQL Servers for our projects to SQL Server 2012. Since we’re not db-admins or familiar with such migrations, I wanted to ask you if you could tell me what we have to be aware of ...
1
vote
1answer
37 views

What happens on the primary when log cannot be restored on the secondary on Log Shipping

I would like to setup a log shipping but I have a concern as to what would happen if the restore operation on the secondary would fail for some reason. I want the primary database keep working no ...
0
votes
1answer
57 views

Why the operation is not rolled back?

I have the following code in a trigger (AFTER INSERT, UPDATE): BEGIN IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION; RAISERROR('Does not allow modifications in the past', 16, 1); RETURN; END; ...
0
votes
2answers
121 views

Can I stop a SQL database backup after it has already started?

I am looking to do a full database backup of a SQL database in SQL Server 2008. My questions are: *Can I stop, pause, or cancel the backup after it has started if it is taking too long or slowing ...
0
votes
1answer
37 views

Database state set to an earlier state before creating new indexes

This is a remote server (SQL Server 2008). We are trying to get benchmarking of some stored procedures. One stored procedure was taking avrg 44 seconds, we have checked this approx 20 times for a ...
6
votes
2answers
2k views

Transaction Log maintenance on Mirror database

SQL Server Version: 2008 R2 Enterprise SP2 I am trying to get a handle on our SQL Server maintenance and I came across something I think is incorrect. We have a single production instance with 3 ...
2
votes
2answers
234 views

How to get OUTPUT $action, Inserted.*,Deleted.* records in In SSIS

I was just wondering, in MERGE in T-SQL, you can output the OUTPUT $action, Inserted.* and Deleted.* records. I want to ask how can I get OUTPUT $action, Inserted.*, Deleted.* records in SSIS?
0
votes
1answer
60 views

SQL Server 2008 and constant expressions

If I have the following scenario, would Replace be evaluated a single time? DECLARE @text nvarchar(32) = 'This is a test field' SELECT textField FROM Table WHERE Id = @idICareAbout AND textField = ...
-1
votes
1answer
62 views

How to aggregate related rows

I want to group these related rows into trips (where each trip consists of a sequence from point 1->2->3->2->1). route Date time ------------------------------- point1 15/10/2014 ...
3
votes
1answer
32 views

How to only restore a specific filegroup?

I am using SQL Server 2008R2 (but I can upgrade if necessary) I have a database with multiple schemas and each schema is on a different filegroup (I wish I could just backup/restore a schema but that ...
0
votes
0answers
146 views

Error while configuring mirroring, Microsoft SQL Server, error : 1418

I have a SQL Server 2008 Enterprise SP1 installed on my both principle and mirror server. SQL Server and SQL Server agent service is also started by same ID having sysadmin rights. But when I am ...
1
vote
1answer
79 views

Unable to restore database

I am trying to restore several databases and I have no clue why some of them fail with the following error: Msg 3634, Level 16, State 1, Line 1 The operating system returned the error '1244(The ...
0
votes
1answer
53 views

Working out Duplicated Data in a Customer Data Base

I have a database in SQL2008 of customers, There is an ID number for the customer. What im trying to do is to create a NEWID field. We have duplicated customers that have different ID fields, I am ...
0
votes
1answer
6k views

Stored Procedure Create Table from Variable with Variable Constraint

I have managed use a store procedure to create a copy of a table with a variable name. But I am struggling to understand how to incorporate a constraint into the stored procedure. The problem: The ...
4
votes
2answers
7k views

How can I backup & restore a single FILEGROUP in Sql Server 2008

Previously, on ServerFault I asked a question about backing up and restoring a Sql Server 2008 Filegroup. Today, when I tried to RESTORE one of these FILEGROUP backups, I got the following error:- ...
0
votes
3answers
318 views

Split date/time range into day ranges [closed]

Using this data (also shown in this fiddle): create table dbo.records ( id int not null primary key identity(1, 1), startdatetime datetime not null, enddatetime datetime not null ); insert ...
4
votes
4answers
3k views

Re enable Windows Authetication in SQL Server

My old employee has disabled Windows Authentication in our server. Now I'm not able to access the SQL Server even though I have Administrator access to the server. I need to reset the sa password. I ...
1
vote
5answers
2k views

SQL Agent still attempting replication for deleted publication

We recently retired a replication publication, deleting each subscription (push subscriptions) and then deleting the publication, all from within SSMS. However, we continue to get the following ...
1
vote
1answer
108 views

Changing Column type to avoid Arithmetic overflow error

I have a table that saves user hits. It has these columns: ID , UserID , HitDate , Userlocation , UserUniqueID Today I'm getting this error "Arithmetic overflow error". After I checked it out I ...
1
vote
2answers
12k views

How to Get the Sum (total) of a column in a query result set

Is there way that I can get the sum of a column in my query result set by just clicking on the column (something like in excel) so that i don't have to copy and paste the column into excel to the see ...
2
votes
1answer
43 views

Restore database with different filename

I have to restore a new back up file daily (as an agent job, after first deleting the existing db) but the file name will vary as it will include the timestamp as well. How can I achieve this so ...
1
vote
3answers
145 views

New SQL Server 2008 instance, load old instance DB's

BACK STORY: I'm a developer with a local instance of SQL Server 2008 on my workstation. I just recently upgraded my motherboard and found out (much to my dismay) the old motherboard's RAID drivers ...
6
votes
4answers
12k views

How to query last restore date in SQL Server?

Is there a TSQL query that shows the last restore datetime for a certain database?
0
votes
0answers
10 views

Linked Server from SQL Server 2008 to Oracle not working

I have tried to make a linked server from SQL server 2008 to Oracle Server. I have successfully made a Linked Server from another machine to that oracle server but the one I'm making on my machine ...
0
votes
1answer
56 views

reuse of temp table getting more time to execute

i'm creating temp table as, SELECT T.CD, T.OBJECT_CD, T.PRICE INTO #TEMP FROM TABLE_NAME T EDIT : ADDED CLUSTERED INDEX TO TEMP TABLE CREATE CLUSTERED INDEX IX_Temp_OBJECT_CD ...
1
vote
1answer
48 views

Minimum SQL Server rights that allow viewing column default values

I have an SQL Server 2008 database, some of the fields (columns) in some of the tables are configured with default values. I have a requirement to limit user security as much as possible, ideally ...
7
votes
5answers
38k views

Writing select result to a csv file

We need to write the SELECT query results to a csv file. How can it be done using T-SQL in SQL Server 2008 r2? I know that it can be done in SSIS, but for some reasons, we don't have this option. I ...
0
votes
0answers
61 views

Accidentally deleted records in MS SQL Server 2014

I have a very big problem with SQL Server data lost. Recently, i have performed SQL replication. and i found out that all exising records/rows in the subscriber was totally erased and replaced by the ...
0
votes
0answers
21 views

Altering the size of user defined datatype in SQL Server

I had created the user defined datatype varchar(5)..But now i have to change the size as varchar(10)..the thing is the udd is used in many tables.. can anyone help me to change the size without using ...
-1
votes
1answer
37 views

Is there a way to copy/initialize values in a set

What I want to do (I know this does not work) is: update stats set BandwidthLastMonth = BandwidthThisMonth, BandwidthThisMonth=0 where myPk = 3 Is there a way to do this in a select ...
0
votes
0answers
25 views

SQLServer dependency graph and performance

I have a large stored procedure running on SQLServer2008 to produce a report on the previous day's data. It rehashes data from 12 tables, including a lot of ORDER by date and CASTS. Among others, it ...
1
vote
1answer
59 views

how to included concatenated values in Dynamic Pivot Column Value

I am extending a dynamic pivot query. The original query works fine. In the second query Instead of display the date as a value for the pivot column I would like to display a concatenated column ...
7
votes
3answers
12k views

SQL Server NTFS allocation unit size

On Windows 2008 R2 running SQL Server 2008 R2 how imporatant is the NTFS allocation unit size on DISK IO performance. It appears to me that server admin who built the few servers for a mission ...
0
votes
1answer
147 views

How to add a default null row if no results from the dynamic pivot query [closed]

I execute this procedure and display results in my application. If my query does not return any results, I still need to print out the column headers and since its a dynamic query I cannot hard code. ...
0
votes
2answers
44 views

Error with making backup in sql Server

We have a win server where installed sql server 2008. When I try to backup database, I have an error. Is anybody know what is the error? TITLE: Microsoft SQL Server Management Studio ...
1
vote
1answer
48 views

How can I get a local variable that's a list in a stored procedure?

I have some code in C# I'm trying to move to a stored procedure - Sql Azure does not like multiple calls. So everything needs to get moved to a proc. Here's the C# code: List<string> ...
0
votes
1answer
24 views

How can I get all rows of data not included in a TVP

I am trying to do the following: declare @domains DomainNames; declare @CompanyId int declare @CompanyName varchar(255); declare @deletedList DomainNames; set @CompanyId = 239; set @CompanyName = ...
1
vote
3answers
121 views

Restoring SQL Server database with CDC

I want to perform a database restore on SQL Server 2012 and copy the database to a different server. CDC is enabled on the original database. I have managed to copy the database along with the CDC ...
0
votes
2answers
124 views

CREATE DATABASE permission denied in database 'master'. unable to get the permission

I am making a database in sql server and it shows an error that "CREATE DATABASE permission denied in database 'master'" I am using the administrator log in itself. What i need to do? Please suggest a ...
5
votes
3answers
243 views

How do I find I.O. statistics (by index) for queries in progress

By running SET STATISTICS IO ON before running a SQL query, I can get an idea of the number of logical reads performed on each index after the query completes. By looking at the view ...