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)

0
votes
0answers
41 views

Where can I find exact rules of a collation?

Is there any documentation anywhere for the exact sorting/equality rules defined by a collation in Windows (SQL Server), for instance "Finnish_Swedish_CI_AS"? I know about CI/CS, AI/AS etc, but I'm ...
1
vote
2answers
80 views

JOINS - optimize cost of LIKE/OR criteria

The Active table has the Account Name in 1 column and the Master table has the Account Name in any one of 6 separate address columns and I'm trying to match them. Also, they don't necessarily exactly ...
1
vote
0answers
15 views

restore multiple .trn logs in SQL 2008 R2 [duplicate]

I am using SQL server 2008 R2 and need to restore 36 .trn logs to a database. I have restored the first 4 using the restore transaction log functionality in SSMS (right click database > tasks > ...
2
votes
2answers
554 views

Export a table and zip with password

I would like, from TSQL, to use a view to extract data from a table, output it with BCP, then use non 3rd party tools to ZIP it with a password and AES encryption. Optionnally, I could use a 3rd party ...
1
vote
1answer
151 views

Identity column value falling behind randomly

We are having a strange intermittent issue where the identity column value falls behind the MAX(ID) for the table. Each customer gets their own table that stores statistics to the tune of [dbo].[...
0
votes
0answers
69 views

Pulling Records from Linked Tables in MS Access, throwing Syntax error

I'm currently working with an MS Access database that I'm supposed to be modifying a bit. I've finished the work I was assigned to do but am now struggling with deploying it accross a multi-user ...
2
votes
2answers
132 views

Why would you put Identity Increment other than 1 in SQL? [closed]

In SQL Server, you can set the increment of an identity column other than 1. In what situation would you do that?
1
vote
1answer
63 views

Safe delete Transaction Log in SQL Mirroring scenario

We are using SQL Server Mirroring with a witness (High Safety mode) and we see the transaction log on the Principal Server has grown around 20 GB in few weeks. I looked around on SO and google for ...
13
votes
2answers
160 views

Index on a persisted computed column not seekable?

I have table, called Address, that has a persisted computed column called Hashkey. The column is deterministic but not precise. It has a unique index on it that is not seekable. If I run this query, ...
2
votes
2answers
157 views

How to get 5min date interval from stock data

i have a stock data of comapy as shown below id update time price 5 2015-07-17 09:02:00.000 65.5 5 2015-07-17 09:03:00.000 65.5 5 2015-07-17 09:05:00.000 65.5 5 ...
0
votes
2answers
125 views

How to make SQL Server 2008 compatible to SQL Server 2000

I have to run the backup of SQL Server 2000 in SQL Server 2008. While restoring the database from the .bak file, I got the error specified cast is invalid After doing google I feel there is ...
-1
votes
1answer
71 views

Group by creating problem in Ranking of player [closed]

CREATE Table dbo.[#TMP] (UId uniqueidentifier, Points int, DC datetime, CId int, Username nvarchar(50)) BEGIN ...
3
votes
0answers
55 views

Could you please describe how SQL Server 2014 do cardinality estimation of Join predicate? [duplicate]

I found the information about CE of single filter predicate, multiple filter predicated but I have not found anything about JOIN predicate.
1
vote
0answers
37 views

Mysteriously Updated Rows

Here's the trigger causing the problem: USE [SalesDb] GO /****** Object: Trigger [dbo].[trgAfterUpdate] Script Date: 7/16/2015 6:34:01 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ...
1
vote
1answer
80 views

SQL Server Client Tools: How can you tell what SQL edition the client tools are from?

While working on SQL Server: Unable to save import export package, but am on Standard Edition , the question came up: We know how to ask SQL Server what edition it is. (Look at properties of server ...
6
votes
2answers
2k views

FOR XML could not serialize the data because it contains character (0x0000)

I have a big query (if necessary I will post it here) and I'm getting this error: Msg 6841, Level 16, State 1, Line 1 FOR XML could not serialize the data for node 'NoName' because it contains ...
1
vote
2answers
2k views

Restore SQL Server 2008 database onto SQL Server 2014?

I have a backup file that I need to restore daily on schedule based. But the backup file is from SQL Server 2008 and restore destination is SQL Server 2014. And also the backup file is from cross ...
6
votes
3answers
2k views

SQL Server job hanging and can't be stopped

I am using SQL Server 2008 R2 (10.5.2500.0) and we have a job that runs every weekend. It runs the ola.hallengren.com database maintenance tool to backup several databases, then FTPs the backups off ...
1
vote
0answers
69 views

Database fragmentation and heap SQL Server

We have critical performance issues with our production database (its around 300 gb size) We have run the following script for a few huge tables : DECLARE @db_id SMALLINT; DECLARE @object_id INT; ...
0
votes
0answers
53 views

What happens to the database structure when i add a nonclustered index

Our team is working for a while now with Azure SQL. After a lot of trying , we managed to add a sync group between the main DB and the backup one. Of course, this means that for every change in the ...
3
votes
2answers
1k views

How can I run a SQL job every 1 second? [duplicate]

I have an SQL Job which processes minimum amount of rows at a given time. Currently its running every 10 seconds which is the minimum available in Job Scheduler. But because of that the table used ...
0
votes
0answers
46 views

windows 2012 r2 how to test drive is 64 or 32 bits

I am following a pre-installation document for sql server 2014 on windows server 2012 r2 one of the items is about the storage, it needs to be 64 bits. Confirm Storage is Set Correctly Confirm that ...
1
vote
2answers
116 views

When to prefere a truncate over a batch-delete?

When I browse DBA-Reactions I understand nearly all the .gifs but with this one I have trouble: https://twitter.com/DBAReactions/status/613840893322338304 I mean truncate obviously doesn't create ...
1
vote
1answer
277 views

sql join query through Adventure works database [closed]

I want to show a list of Product Colors. For each Color then show how many SalesDetails there are and the Total SalesAmount (UnitPrice * OrderQty). Only show Colors with a Total SalesAmount more than $...
1
vote
1answer
39 views

Get new ID for inserted ID that comes from another table?

Simple question but I'm a newbie. I have existing orders table 'Orders'(table1) and it has an OrderNumber as a column and the orders are number up 156. I have a existing table called 'orders'(table 2)...
0
votes
1answer
67 views

NC Index not being used [closed]

I have a table (9mm records) with a field called filename nvarchar(max)(I didn't decide on this datatype and can't change it). I'm wanting to count how many records meet the following criteria: ...
4
votes
1answer
87 views

SQL Server 2008 R2 : LDF file size not increasing

I am using SQL Server 2008 R2. I have a table statDB of 100 GB in primary filegroup. I have created a secondary filegroup in same database (Lab1) and created a table copyStatDB. Now I start copy ...
0
votes
1answer
324 views

Restore Database in SQL Server 2014 with different name

I am using SQL Server 2014. I have a database but as the user deleted some records, I need to create another database with a different name and then transfer the data from the restored database to ...
3
votes
2answers
241 views

Effective indexing and querying of overlapping date/time ranges

I have a table with the following schema: AccountId: int StartDateTime: datetime2(0) EndDateTime: datetime2(0) I want to be able to query this for rows with a certain AccountId, and whose date ...
4
votes
4answers
2k views

SQL Server - Alter table vs drop and create

Our database is SQL Server 2008 R2. We have some tables that have some varchar(500) columns that I want to switch to datetime2 or bigint. I can guarantee all the data in the columns to be switched are ...
0
votes
1answer
116 views

AWS RDS query running extremely slowly

I am testing out AWS RDS to replace a local DB and in general I am finding the latency etc acceptable for most of our use-cases. There is one particular query that we run manually (i.e. in SQL Server ...
-1
votes
2answers
77 views

Under what circumstance would setting MaxDop to anything other than 1 cause an issue? [closed]

we are having continued discussions with our vendor whom is insistent on setting MaxDop to 1 we have performed internal testing and see a general 20% performance improvement by setting this to 4 ...
0
votes
1answer
19 views

Slow fill database

The source sends in my program a large number of rows. When the number of rows such as two thousand per minute for one table, all is saved in the database properly. But if you send two thousand per ...
2
votes
3answers
377 views

SQL Server Slowdown?

We're a small shop, and I'm certainly not a DBA by any stretch of the imagination, but I've recently inherited a somewhat large older database (been running since at least 04), that in the past month ...
1
vote
0answers
44 views

Lookback Query utilizing Change Data Capture in SQL Server 2014?

I'm using SQL Server 2014 to maintain a small database and while looking for a way to keep a History of my Data I came upon the Change Data Capture Mechanism. My question now is if there is an easy ...
0
votes
2answers
93 views

Display Total under name column and sum of amount under sal column [closed]

in a table empno,ename,sal,hiredate is there. but i want output is empno ename sal hiredate 122 ganga 2000 1989-02-06 123 reddy 3000 1986-06-02 Total 5000 here empno, hiredate column ...
1
vote
1answer
51 views

Reclaim unused space

I have a DB 150 GB , contains 138 tables one of the tables is 120 GB. I need to archive around 80 GB from this table. Is there a way to reclaim this space without using DB shrink? thanks
1
vote
1answer
87 views

Is it Possible that a variable name changes in a stored procedure after a restore?

I often restore my Testing database from Production db, but this time I noticed something odd: we have a stored procedure called (USP_AddTS), one of its variable names have slightly a different name ...
6
votes
1answer
656 views

SQL Server: Unable to save import export package, but am on Standard Edition

I am confused. Issue: SSIS ("SQL Server Import Export Wizard") should let me build a data import package and save it to a file, for easy re-running (converting to a task, etc.). I want to save a ...
3
votes
1answer
240 views

What is the relationship between the SSIS Package Store and Catalog?

I have a server with a working installation of the Sql Server 2012 SSIS Catalog. I need to set up an additional instance including the SSIS Package Store service as an interim step while the packages ...
1
vote
1answer
103 views

Most efficient table storage for determining recurrence

What is the most optimal table structure to store schedules / recurrence definitions so that we can efficiently query it for all events that will occur within a date range (min:1 max:32 days)? My ...
1
vote
0answers
89 views

SQL Server tool for merging rows [closed]

We have a SQL Sever 2008 database that occasionally receives bad data from customers. The issue we are trying to address here is that sometimes duplicate records are created where one row has some of ...
2
votes
1answer
703 views

Process Data cube from job on SQL server

I have an SQL Server Agent job on server(X) that has a step that is supposed to process a data cube on a remote server(Y). Whenever I run the job it fails and says that server(X) does not have ...
3
votes
1answer
61 views

Determine Gap Records, Fill and Return Result

The following working code targets SQL-Server 2012 and I have distilled the actual problem into a manageable scenario with the code example shown below also presented on SQL Fiddle. I seek feedback ...
0
votes
0answers
45 views

Refactoring 80 GB table that stores massive amount of calculated results

Trying to evaluate architectural changes to improve the performance of an app that calculates a lot of individual values and stores each of these results as a row. The storage size for one of the ...
1
vote
1answer
78 views

Best way to back up data bases on a SQL Server Availability Group DR Site node

I have an Availability Group (Primary only is readable) with 2 nodes locally and 1 node at a DR site. Both sites have a backup system. Locally, I’m using the local backup system to back up the AG ...
3
votes
2answers
371 views

Historical dbcc checkdb results

Is there a better way of accessing historical dbcc checkdb result history (if output logging was not used at runtime) than xp_readErrorLog? EXEC xp_readErrorLog {0-20}, 1, N'CHECKDB'; SQL Server ...
2
votes
0answers
38 views

SQL Server database suspect

All the databases went to suspect mode on a server. Tried bringing on-line by taking emergency but did not workout . Have restarted the server as there is disk I/o error still in suspect mode. Can ...
1
vote
0answers
298 views

Could not redo log record on mirror

One of my database mirrors is in the suspended state today and the error log on the mirror shows the following. Could not redo log record (338934:102862:477), for transaction ID (0:848150408), ...
-1
votes
1answer
68 views

Insert id into another table and give the item another id that is autocrementing?

Need this answered if anyone can help. I need to create a query that will automatically insert ordID, but give it a new auto incremented OrderNumber in Orders.dbo. Fiddle is below: http://sqlfiddle....