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
2answers
67 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?
0
votes
1answer
21 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
94 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
90 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
72 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
66 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)) ...
3
votes
0answers
49 views

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

I found the information about CE of single filter predicate, multiple filter predicated but I have not found anything about JOIN predicate.
0
votes
1answer
40 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 ...
3
votes
2answers
66 views

For XML PATH error (SQL Server 2008 R2) [closed]

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
60 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 ...
4
votes
3answers
81 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
43 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
36 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 ...
1
vote
2answers
60 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 ...
1
vote
2answers
45 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
41 views

sql join query through Adventure works database [on hold]

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 ...
0
votes
1answer
55 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
41 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
34 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
71 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
430 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
24 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
49 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
17 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
138 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 ...
0
votes
2answers
39 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
28 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
62 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 ...
4
votes
0answers
41 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 ...
1
vote
1answer
26 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
33 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
41 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
54 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
39 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
40 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 ...
2
votes
1answer
37 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
46 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
29 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
17 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
32 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: ...
0
votes
0answers
27 views

Shrink database or DB files not reducing size even after dropping biggest table

Our MDF file was originally 550GB in size (log is just 10MB), and the biggest table we had [HourlyCounters] was 140 million rows with 580 columns (varchar[50]). It's a table with a very inefficient ...
0
votes
0answers
18 views

Proxy for MDW data collection on remote servers - SQL Server 2012

I am trying to setup data collection (for disk usage) from remote servers and upload it to my MDW database. I understand I will need a proxy set up for the agent to do this but which subsystem to I ...
3
votes
3answers
379 views

Convert date yyyy-mm-dd to integer YYYYMM

How can I convert @dateb: SET @dateb = dateadd(month, datediff(month, 0, getdate()) - 3, 0) that returns 2014-04-04 as date to an integer of 201404 Thanks
0
votes
0answers
16 views

Shrink database or DB files not reducing size although I dropped biggest table

Our MDF file was originally 580GB in size, and the biggest table we had [HourlyCounters] was 140 million rows with 580 columns (varchar[50]). It's a table with a very inefficient schema, but there's ...
0
votes
0answers
10 views

Hide table object from db_datareaders

Is there a way to grant select on a view without having to grant select on the underlying table object too? Problem is: 2 users share the same table. Both currently have db_datareader privileges. ...
1
vote
1answer
21 views

Attach Database is disabled in Microsoft SQL Server 2012 Management Studio

I have buy from Godadday hosting and domain, after that I have create database in godaddy and the connect to this db using my authentication. I have .mdf, .ldf that need to attach to the connected ...
4
votes
1answer
34 views

Limiting Domain Admins permissions on a SQL Server

I have a SQL Server 2012 machine and I want to limit the Domain Admins permissions. What can I do to make sure that the Domain Admins have read only permissions for the databases and nothing else for ...
0
votes
1answer
40 views

Failed SQL Login - Source server same as destination cannot locate SPID SQL Server 2014

Bit of a confusing one here. We are getting repeated messages in the SQL Server error log as below for a SQL Server instance: NT AUTHORITY\SYSTEM Reason: Failed to open the explicitly specified ...
0
votes
1answer
57 views

SQL Server transactional replication issue with database

We have on the server a database and we want to replicate a database on another server. we've set a transactional replication, but we have issues with the default constraints on the tables: On the ...
0
votes
2answers
50 views

Auto increment a value using cursor in SQLServer

I am developing an employee leave management system and My table structure with data is : +-----------+---------+----------+----------+------------+--------------+ | EmpID | CL | PL | ...