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)

1
vote
2answers
455 views

Metric to standard unit conversion in SQL Server

I am giving simplified version of my two table which are as follow. tblRecords ID unit val --- --- --- 1 KV 3 1 BAR 4 2 KV 7 2 KG 5 3 C 37 tblUnit unit ...
2
votes
2answers
557 views

T-SQL - How to filter data from table

I'm new in DB world, so if you can help me it would be great. My problem: I have filtered some data and got a table with data, but need to filter them again. Picture might help you. For me, it is ...
2
votes
1answer
151 views

Logging errors with extended events excluding some users

I use extended events to store database errors, like this: CREATE EVENT SESSION [ErrorCapture] ON SERVER ADD EVENT sqlserver.error_reported ( ACTION ( sqlserver.client_hostname, ...
1
vote
2answers
4k views

DBCC SHRINKDATABASE TRUNCATEONLY 2008R2 vs 2012

Im a bit confused was the TRUNCATEONLY parameter changed in 2012 or is the documentation wrong in 2008R2? 2008R2 Releases all free space at the end of the file to the operating system but does ...
1
vote
1answer
123 views

Starting up sql server after hard-drive recovery

So I'm in a bit of a pickle. My primary work computer has recently crashed and some of the windows files were corrupted I tried repairing but did not work. This computer was running a program that ...
0
votes
2answers
3k views

How to read “CPU (ms/sec)” in the “Recent Expensive Queries” of Activity Monitor?

Is CPU (ms/sec) the cpu time in ms in previous second? If it reaches 1000, does it means that it uses 100% CPU? However, on my 8 cores server, the % Processor Time is usually very low like several ...
1
vote
1answer
97 views

how do I check the last time dbreindex or an index defrag was executed

Is there a quick tsql I can use to check when was the last time a dbreindex, index defrag and update stats was executed on the database? Appreciate everyone's quick response.
-1
votes
2answers
201 views

Insert into an empty table with or without clustered primary key? [closed]

I will need to insert some rows in an empty temp table. The table has PK of (month date, id char(10)). The source table is partitioned by month. Which of the following is faster? 1a) the target table ...
4
votes
2answers
131 views

Central Management Server - can it manage itself?

I'm setting up a SQL Server 2012 lab on Windows 2008 R2 which has 5 SQL Servers. I registered SQL1 as my central management server and created a group under this server that includes all the servers ...
1
vote
1answer
2k views

Some queries are very slow after index rebuild

After finding out almost all databases on my SQL Server had fragmentation over 40%, I decided to do an index rebuild on all tables using a fill factor of 80. After rebuilding all indexes, some ...
0
votes
2answers
233 views

Resume log shipping from a specific transaction

Is it possible to force SQL Log Shipping to run from a given .trn file onward? I have two databases, where one ships to another this was working fine. However I had to restore the primary database ...
0
votes
1answer
52 views

SQL Server 2012 Intellisense Support for Extended Events

Using SQL Server 2012 with SP1 for some reason when try to use extended events programmatically using T-SQL. I am not able to see intellisense working? Just trying to check is this something on my end ...
1
vote
2answers
892 views

Delete rows from a large table with joins and aggregating (resulting in 1 % less rows in the big table)

I got a bit stuck on performance, so I thought about asking a bit of help. I have a working query, but unfortunatelly it feels rather slow and I know it's not as performant as it could be made ...
1
vote
1answer
273 views

Why DBCC CHECKDB is multiple times in error log

I have an issue with dbcc checkdb command . In the errorlog file I find the dbcc checkdb command multiple time within the interval of 30-45 minutes. I have scheduled a job which grep keyword error ...
1
vote
1answer
590 views

How to update where subquery value is null in SQL Server

I am attempting to update a column if another value from a subquery is less than a certain value or null: UPDATE Customer SET PriceClassID = 'A' FROM (SELECT custid, SUM(curybaldue) as last_sum FROM ...
8
votes
3answers
3k views

Can I create a user defined table type and use it in the same transaction?

When I execute the following (in management studio, GO will separate the commands into batches) use tempdb begin tran go CREATE TYPE dbo.IntIntSet AS TABLE( Value0 Int NOT NULL, Value1 Int ...
10
votes
1answer
323 views

Should NOT IN be avoided?

Among SQL Server developers, it's a widely held belief that NOT IN is terribly slow, and queries should be rewritten so that they return the same result but do not use the "evil" keywords. (Example) ...
4
votes
2answers
182 views

Make “as” mandatory when create column alias?

We found a lot of bugs are caused by missing comma, select aaaa, bbbb -- forgot comma ccc, dddddddd, ..... Is it a way to make expression name invalid and it must be expression as ...
2
votes
2answers
200 views

What can be done to further enhance performance of Multiple Join and Aggregate Queries?

I have a typical star schema simulated here, and I am mentioning two queries: first query simply joins the fact table with 2 dimension tables and 1 calendar table, and the second query joins and ...
3
votes
3answers
4k views

What permissions are necessary for truncating a table?

I have a sql account with the following permissions on a database: The db_executor role you see this account being a member of was created by this script: CREATE ROLE [db_executor] AUTHORIZATION ...
0
votes
1answer
805 views

Create temporary tables per session in a DB other than tempdb

Using SQL Server, Is there a way to create a temporary table per user session in a user database in the same exact way they are created in tempdb? Using tempdb is fine in most cases, but some of the ...
3
votes
0answers
165 views

Why are we suddenly getting time-outs on multiple transactions? [closed]

Two days ago the transaction log filled up and my user's couldn't update or insert. One of my techs truncated the log, shrank the db, then did a full backup. The next day (Monday) we noticed that ...
3
votes
1answer
2k views

SQL Server cluster not available after failure of the “main” server

I aksed this question on stackoverflow, but was asked to repost here so here it is: I have a database that I'm setting up in a clustered environment. It'll be two servers with a shared storage. ...
0
votes
2answers
593 views

SQL Server Agent: QUOTED_IDENTIFIER

The scenario is rather simple: A Job fails in production, giving off an error "ALTER INDEX failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER' ...". The question is, ...
2
votes
1answer
376 views

How do I find the longest string in a row amongst various text fields?

Does anyone have an easy query to find the longest string of characters in a data row from ALL alphanumeric (text, nchar, varchar, etc) type columns from ALL tables in a single SQL Server 2008 R2 ...
2
votes
2answers
3k views

How do I add a MySQL linked server to SQL Server?

I am trying to add a linked server on SQL Server to MySQL Server. Note the SQL Server is installed on a separate machine with a different domain name. The SQL Server is 10.0.1.1 on old_domain.com. ...
3
votes
1answer
1k views

Table-valued function runs fast, but slow from another function [closed]

Disclaimer: I'm a senior sysadmin who's trying to help our development team speed up the production database. Our users are hurting, bad. Please don't shoot me for not being great with SQL The ...
0
votes
3answers
118 views

Why is my SQL server using ~4 GBs of memory?

I notice that pretty often my SQL server will eat up 50% of my 8GB of memory. This usually happens after I finish running some SQL queries, not while they're running. The most common query is one that ...
1
vote
3answers
722 views

GUID stored in a varchar field

I have inherited several databases that use GUIDs as PKs. Instead of all the datatypes being uniqueidentifier most are varchar(50) and some varchar(100). Fields are true GUID some where created by ...
1
vote
1answer
103 views

sp_grantdbaccess cannot be run in a stored proc owned by DBO?

Maybe I'm getting this wrong, but... I have a SQL Server 2000 database with a stored procedure that is owned by DBO. This stored procedure is calling sp_grantdbaccess, which can be run by DBO, ...
4
votes
1answer
66 views

How can I script out a copy of the backup to multiple locations?

Is there a way to script a copy of the backup file to multiple destinations? For example, the following will split the backup into 3 segments which make up the entire backup file. But, I'm looking to ...
0
votes
1answer
31 views

How can I write to replicated environments without impacting production? [duplicate]

Are there any methods (mirroring, snapshot replication, change tracking, etc...) available in SQL Server 2k8 which would allow me to replicate production data to several individual development ...
4
votes
1answer
67 views

Query uses Primary Key Index instead of Nonclustered index defined

I have this simple query and I am confused why the index is not working. SELECT lop.RecordID ProspectusID, c.c_code CourseCode, c.c_desc CourseDescription, COALESCE(c.c_major, '') ...
2
votes
1answer
103 views

Confirmation on query optimization and performance understanding (seek and scan)

I am following along with this video on SQL Server query optimization and I would like to check my understanding of the results I am seeing. I am using SQL Server 2012 with the AdventureWorks 2012 ...
6
votes
2answers
209 views

Figuring out the physical size of a group of tables in SQL server

I have a group of about 30 tables, and I want to know the physical size on disk of all of these tables (plus indexes). Is there an easier way of doing this than through the GUI in SQL server 2008 R2? ...
2
votes
0answers
1k views

SQL Server intermittent error 40 Could not open a connection to SQL Server or The network path was not found

I am getting intermittent errors as per the below stack trace. I am using C# Entity Framework with SQL Server 2012 enterprise running on a separate server computer. I can connect and query the DB ...
0
votes
1answer
569 views

How to auto start instance of sql server 2012 localdb on startup?

How do you auto start instance of sql server 2012 localdb on startup?
0
votes
2answers
136 views

SQL Server 2005 Replication Stops after a minute without an error

Background: I have a SQL Server 2005 setup with master, slave1, slave2 replication set up as a pull replication from slaves. The distribution database resides on the slave1 machine, both slaves pull. ...
1
vote
1answer
143 views

SQL Server “Max Worker Threads” Setting

I am helping troubleshoot some problems on a SQL Server box. An application that used to run without problem is now failing with connection pool errors, and no changes have been made to the ...
1
vote
2answers
384 views

Cannot add an account [non domain account ] to SQL Server 2012

Background: I have a application pool [ABCDEMO] in IIS. The identity of the appool is "NetworkService". I am trying to add IIS APPPOOL\ABCDEMO to my SQL SERVER 2012 on a Windows SERVER 2012. When I ...
2
votes
2answers
72 views

How to revert multiple impersonations?

When there are nested impersonations (as in exec as user = 'user1'; exec as user = 'user2'; exec as user = 'user1';), is there a way to revert all of them without having to use the revert command ...
1
vote
4answers
228 views

Which of these queries is best for performance?

Which of these queries are best for performance ? Sometimes I wonder if SHORT scripts really is the best thing to focus on. These scripts performs the same task. With left joins i can achieve what i ...
2
votes
3answers
2k views

Is replication possible on two different domains?

I am implementing a database replication between different geograhical locations where each one is on a different domain. After going through all the process, when I start the agent it runs and stops. ...
0
votes
1answer
1k views

SQL Server 2012 Service Master Key Regenerate

I have a new SQL Server 2012 instance and when I run the following command I get an error. ALTER SERVICE MASTER KEY REGENERATE Error: Msg 15329, Level 16, State 1, Line 1 The current master ...
0
votes
3answers
103 views

SQL Server Facets: “Linked Server” exist but “Registered Server” doesn't - why?

I'd like to monitor multiple SQL Server instances. Something similar to what is described in "Monitor Your SQL Server Linked Server Configurations with Policy Based Management" but instead of using ...
0
votes
1answer
257 views

Is the [NT Service\SQLSERVERAGENT] a supported type for SQL Server Agent service?

Reading and re-reading MSDN "Select an Account for the SQL Server Agent Service". NT Service\SQLSERVERAGENT is not listed in the "Supported Service Account Types" section. And, if not, what is it ...
4
votes
1answer
554 views

Any way to send notifications to different Emails on success/failure of SqlServerAgent job?

SQL Server 2012 R2 on Windows Server 2008R2 Is there any way to send notifications to different Emails: on success of an Sql Server Agent job to one Email address and on failure - to another ? ...
0
votes
1answer
298 views

Data Warehouse - Slowly Changing Dimensions with Many to Many Relationships

As an example, let's say I have a fact table with two dimensions and one measure FactMoney table ProjectKey int PersonKey int CashAmount money The two dimensions are defined like this: ...
1
vote
2answers
156 views

SP or query to dump “password policy” checkbox for all logins

sp_helplogins doesn't show a column for this. I need a listing of all logins, with the status of their "Enforce password policy" checkbox. This is for an auditor, and the standard practice is for ...
0
votes
1answer
73 views

Compiled version of stored procedure

If I have administrator rights, would it possible to view details on the compiled version of a stored procedure or a view? Is there a visual representation available?