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)

7
votes
1answer
154 views

IN and NOT IN for XML column

I have a table with a xml column. Xml is similar to <Root> <Row> <user>abc</user> <Rowid>1</Rowid> </Row> <Row> ...
8
votes
2answers
12k views

Which one is more efficient: select from linked server or insert into linked server?

Suppose I have to export data from one server to another (through linked servers). Which statement will be more efficient? Executing in source server: INSERT INTO ...
3
votes
2answers
3k views

Installing Full Text Search to SQL Server 2008 R2

I installed sql server 2008 R2 Express successfully, then realised I need to get Full Text Search. So I downloaded the "Advanced Services Installation Package", but when I run it there is no option in ...
4
votes
6answers
15k views

Don't use a transaction for Stored Procedure

I have a stored procedure that runs a few commands. I don't want these commands to be wrapped in the transaction of the stored procedure. If the 4th command fails, I want the 1st, 2nd and 3rd ones to ...
2
votes
2answers
237 views

How to join multiple tables (SQL) to find the difference between an order and shipped quantities?

I have a collection of orders that were submitted to an internal ERP, which were processed and partially shipped. The table hierarchy is as follows: Order table contains OrderReference(PO), OrderID ...
0
votes
0answers
26 views

How to join multiple tables (SQL) to find the difference between an order and shipped quantities? [duplicate]

I have a collection of orders that were submitted to an internal ERP, which were processed and partially shipped. The table hierarchy is as follows: Order table contains OrderReference(PO), OrderID ...
0
votes
1answer
92 views

SQL Server Instance Version [closed]

I'm working with a SQL Server with several instances. Four of my instances are at 10.50.2811.0 and the remaining two are at 10.50.1765.0 I've tried running SQL Server 2008 R2 SP1 and CU 6 to get it ...
2
votes
2answers
2k views

SQL server windows authentication through network

I am using sql server 2008 r2.There are about 50 pc in my office connected in network by using LAN.In a sql server 2008 r2 express(installed in windows 8) i have created all users windows account with ...
9
votes
2answers
4k views

Setting variables in SQLCMD mode

Using SQL Server 2008 R2 Enterprise Edition Consider the following statement: :setvar source_server_name "SERVERNAME\INSTANCENAME" Is it possible in SQLCMD mode to get that value using TSQL ...
6
votes
1answer
2k views

linked list in SQL and Trees

Though SQL is more affiliated with table like operations and not so much with recursive, say we would like to implement the linked (or double-linked) list concept (like we have for instance in C). Is ...
3
votes
2answers
71 views

Backing up the database without compromising performance

I have a data base with a size up to 120 Gb and I need do a backup every night. The problem is that the system needs stand operative all the 24 hours. In this moments the backup takes up to 2 hours ...
1
vote
2answers
61 views

Practical way to temporarily shut down a database

What would be the most practical way to shut down a database to access for any user? I need to practically shut down a specific database on a SQL Server for test purposes, and would like to know the ...
3
votes
2answers
1k views

Copy database, problem with not existing principal

I'm trying to copy a database from a server to my laptop, using Management Studio. However, after about an hour of copying, I get the error Cannot find the principal 'MVGSQL01\itsac', because it ...
0
votes
1answer
56 views

What is a good way to replicate code across multiple databases?

SQL Server 2005 I have two databases (Source1 and Source2) with the same data model and I plan to merge the data into a third database (Target) with an "abstracted" data model. In the future, it's ...
1
vote
2answers
628 views

How do I migrate varbinary data to Netezza?

I got a warning message while migrating DDL from SQL Server to Netezza: Warning: [dbo].[spec_binarymessage].[blobdata] data type [varbinary] is not supported the target system and will be scripted ...
7
votes
1answer
636 views

SQL Server not using available memory

SQL Server 2008 R2 Standard Edition (64-bit) on Windows 2008R2 Enterprise Server has over 300 GB of memory but total memory use in control panel never goes over 86 GB Have SQL configured to use ...
4
votes
3answers
950 views

SQLCMD Exporting 16.5 Million Rows

I am exporting a table to a TSV file using sqlcmd, and I am running into issues. The table has 16+ million rows and about 55 columns. The problem is that it does not export the full table, but seems ...
7
votes
1answer
749 views

SSIS organization

I'm familiar with SSMS, but I've never used .net, c# or visual studio (been doing other things: Assembler, c, unix, vi, oracle, etc). I'm trying to figure out basic 2012 SSIS ETL (no BI or data ...
2
votes
2answers
608 views

Stored Procedure against Linked Server

We have an AX server that we would like a group of users to be able to retrieve data from but limit their access to just the data needed. Normally this could be done with a stored procedure and give ...
-1
votes
1answer
418 views

How to create a mysqldump file automatically from SQL server database on a daily basis

I want to create a mysqldump file from a SQL Server database, I know its possible using MYSQL workBench, what i want is to make it completely automate. So the script runs on a daily or weekly basis ...
4
votes
1answer
362 views

SQL Server 2008: Measure tps / select statements per second for a specific table?

There is a discussion how to measure activity against an entire DB: http://stackoverflow.com/questions/5019593/sql-server-2008-transaction-per-second-for-specific-database My question is narrower. ...
3
votes
1answer
776 views

Page Lookups Percentage - SQL Server performance monitoring

I'm currently doing some work on monitoring SQL Server performance. I've found the following script[1] which calculates 'Page Lookups Percentage' - the suggestion being that a "good" value is ...
2
votes
2answers
564 views

Improve CTE performance

is there a way to improve the performance of a recursive CTE like below, I am unsure if I can add indexes on joins when the joins are using ROW_NUMBER? DECLARE @File_Name VARCHAR(8000), @Disk ...
2
votes
2answers
508 views

SQL Server Trace - Filter on System Processes

Is there a way to filter a (2008 R2) profiler trace on a specific system process? I don’t mean the usual server process (SPID), but the system processes that append “s” onto the end of a SPID (eg ...
21
votes
2answers
3k views

Check existence with EXISTS outperform COUNT! … Not?

I've often read when one had to check existence of a row should always be done with EXISTS instead of with a COUNT. Yet in several recent scenarios I've measured a performance improvement when using ...
-1
votes
4answers
854 views

What is difference between tempdb log and database log? In which circumstances these log files uses?

As we all know there are two types of log file (*.ldf) comes into the picture whenever any large query getting executed 1. database log (transaction log) file 2. tempdb log. Please describe me how ...
4
votes
1answer
262 views

How large are blocks of data in SQL Server?

I'm working in SQL Server 2008 R2 and have created a query that gathers and sums the total of data files and log files' sizes. However, I can't find how much actual disk space a single block of SQL ...
2
votes
1answer
619 views

Creating Indexed View GROUP BY Epoch Date

I have a few big tables with about 6 billion rows that I was looking to optimize. Clustered key is Epoch (unix date time which is the number of seconds that has passed after 1970) and customer ID. ...
2
votes
0answers
431 views

Audit Queries in SQL Server 2008 Including Start Stop Times

I have SQL Server 2008 Enterprise. I know how to set up auditing on the SQL Server, but it looks like the audit logs don't include query start/stop times. We currently use a product called Splunk to ...
3
votes
1answer
570 views

Why does Log Shipping .TRN file copy just stop

I apologize in advance for a long post but I have had it up to here with this error of having to delete LS configuration and starting it over for any DB thats got this error. I have LS setup on 3 ...
2
votes
2answers
7k views

Get username and/or IP address responsible for a query

I use the following query to find performance improvements in queries: SELECT TOP 20 SUBSTRING(qt.text, (qs.statement_start_offset/2)+1, ((CASE qs.statement_end_offset WHEN -1 THEN ...
3
votes
1answer
103 views

Constraint to one of the primary keys as foreign key

Table1: grid_col (col_id,f_id,f_value) (col_id,f_id) is primary key. Table2: grid (grid_id,col_id,text) (grid_id) is primary key. I want to have a constraint for grid that, col_id ...
5
votes
1answer
741 views

IO_STALL question and understanding

I am collecting IO_STALLS from sys.dm_io_virtual_file_stats every 5minutes and then doing a delta to see which files are being affected most by IO. In one 5min period I get a delta of 5826331 ms ...
2
votes
1answer
98 views

Sql Server & NetApp Sql Snap Manager

Does anyone use netapp's sql snapmanager? We are in the process of trying to decide if it is right for us. I know of the more popular features, but am trying to get some real life experience ...
2
votes
2answers
76 views

Lock hints on preconditions

Assuming for a moment that FK references are not available, what lock hints should be placed on the preconditions of the following example to prevent deadlocks and inconsistent data? (This is a ...
3
votes
1answer
465 views

Sql Server 2012 Extended Events for Selective Xml Indexing not showing results

I created a Extended Event to monitor and tune a Selective Xml Index CREATE EVENT SESSION [SelectiveXmlIndexing] ON SERVER ADD EVENT sqlserver.selective_xml_index_no_compatible_sql_type, ADD EVENT ...
4
votes
1answer
743 views

SqlPackage does not pick up variables from profile

I want to upgrade a database using .dacpac and sqlpackage.exe here is how I run sqlpackage: SqlPackage.exe /Action:Publish /SourceFile:"my.dacpac" /Profile:"myprofile.publish.xml" The ...
6
votes
2answers
1k views

TempDB Version Store cleanup

From what I can find the version store will only clean up versions that are older than the oldest active transaction. Question: Is the oldest transaction database specific or will SQL Server keep all ...
1
vote
1answer
466 views

Sneaky rollback in SQL Server 2008 R2

Is it possible for an entire set of committed transactions to be rolled back in SQL Server 2008 R2 without any notification or logging anywhere? We had a set of data apparently get rolled back this ...
4
votes
3answers
2k views

How to undo every change made to a database in a controlled environment?

I'm doing system testing of a product, and several tests are severely changing the data of a demo database. The data is quite complex to create queries which will undo the changes done by the tests; ...
3
votes
5answers
2k views

Combine datetime + string to make a proper datetime

I need to take a DATETIME column (Column A) that contains only a date, then add a VARCHAR(5) column (Column B) which contains a 24-hour representation of a time (i.e. 1330) and combine them to get a ...
3
votes
0answers
197 views

How can I search values, considering occurences, on more than one term in SQL Server CE?

I have a rather complex SQL query, that I actually received help from this SE site to come up with parts of. This query is designed to take a search term and search all relevant values in a database ...
1
vote
1answer
77 views

When do you add your foreign keys?

I'm scripting out a fairly simple database so I can simply hand off a script to someone else for an application to use. I'm curious about where best practice/the community stand on this: When should ...
4
votes
4answers
748 views

Table join to match without duplicates

I have a situation where I need to match arrivals and departures of assets in a location. The problem is that asset movements are not always entered into the database chronologically, nor is there ...
5
votes
3answers
4k views

Can a database's files be copied while a database is online?

I'm working on setting up a development copy of a production database on SQL Server 2008 R2 SP1. The live database is getting lightly used by two developers for read only queries currently, but the ...
3
votes
1answer
311 views

Cumulative Game Score SQL

I have developed a game recently and the database is running on MSSQL. Here is my database structure Table : Player PlayerID uniqueIdentifier (PK) PlayerName nvarchar Table : GameResult ID ...
-3
votes
1answer
134 views

SQL Server: Month Range Join [closed]

Given that there are two dates like 2012-07-08 and 2013-02-06. I need to count record of each user for every month. If there is no data for a user in particular month then it should return zero. The ...
3
votes
3answers
5k views

Difference between Full backup and Copy-only full backup

I saw in this link that full backup does not truncate the log. So what is the difference between full backup and copy-only full backup? For the log backup there is copy-only backup which prevent the ...
3
votes
5answers
457 views

Extract data to another computer

I have SQL Server 2008 R2 Express edition, and I want to export the data in that database to another computer so I can import it again in that computer. How please? What I have tried Right-click ...
2
votes
1answer
170 views

Import issue with Replication

When I import some data from excel file to a table that is part of a merge replication, the data is imported successfully to the table, but those new records are not synced to subscribers that belong ...