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)

3
votes
1answer
220 views

Load Testing Crash Course

Can someone point me at a good resource to get a crash course in load testing. I have a sql server machine that I need to load test but I havent been thruogh the process before. Also we do not have ...
4
votes
1answer
78 views

Covering Index Question

I have the following query Select Pt.PRODID, PT.INVENTREFID, Inv.ItemName, PT.ItemID, Configid, Pt.QTYSCHED, PT.DLVDATE, Pt.CREATEDDATETIME, pt.SCHEDEND, CASE Left(PT.INVENTREFID, 3) WHEN ...
10
votes
3answers
2k views

Unique Identifier with Extra Characters Still Matching in Select

We are using SQL Server 2012 with a unique identifier and we've noticed that when doing selects with additional characters added onto the end (so not 36 chars) it still returns a match to a UUID. For ...
2
votes
2answers
798 views

Is there a way that I can export a list of all table triggers on a server?

I have two SQL Server instances that I manage. One is a SQL Server 2000 instance, and the other is 2005. Some where, on these servers, I recall setting up a couple table triggers that were executed ...
2
votes
1answer
843 views

How can I calculate time spent at work in a single column?

I would like to calculate the amount of time spent working from rows of data that contain a single date/time field. The first occurrence on a given day can be considered the start time, with the ...
3
votes
2answers
2k views

Why do I get “The initial snapshot for publication is not yet available.”?

We are using Transactional Replications with updatable subscriptions. 1 publisher, 1 subscriber. SQL Replication started encountering a constraint error on 3/6 at 10AM because people at two different ...
1
vote
2answers
117 views

Does this query make sense?

I recently migrated a database from Sybase ASE to Microsoft SQL 2008r2. One category of queries that was broken in transit is: SELECT person_id FROM leaveperiods WHERE group_id=146 GROUP BY ...
2
votes
3answers
18k views

List all permissions for a given role?

I've searched around all over and haven't found a conclusive answer to this question. I need a script that can give ALL permissions for an associated role. Any thoughts, or is it even possible? ...
5
votes
3answers
2k views

Linked server error not caught by TRY-CATCH

I am setting up a job to loop through a list of linked servers and execute a specific query against each one. I am trying to execute the query inside a TRY-CATCH block so if there's a problem with one ...
4
votes
3answers
360 views

Backup strategies for zero data loss

I am working on one project and it has around 100K records. We can afford a downtime of 1 day but we need the data to be always available to us in latest state. I've gone through two options: 1) ...
0
votes
1answer
45 views

Copy Permission From Windows Based user To Local user

I want to know if it is possible to copy the permissions of a windows user to a locally created user on SQL server?
13
votes
4answers
2k views

Is it possible to make one column readonly?

I'm curious if it is possible to create a table with a column that can never be changed, but the other columns of the table can. For instance I could imagine a CreatedByUser column that should never ...
3
votes
0answers
147 views

Key Lookup and Full-text index

I have the following query: SELECT T2.Title FROM TitleTable T1 INNER JOIN TitleTable T2 ON T2.FKID1 = T1.FKID1 WHERE T1.FKID2 = @ID_PARAM1 AND T2.FKID2 = @ID_PARAM2 AND ...
0
votes
2answers
326 views

Large time difference between two almost identical simple queries…why?

I'm trying to understand why is there so much difference in execution time and CPU usage between two simple queries that only differ in a computation. The queries are the following: SELECT ...
5
votes
2answers
187 views

Is it possible to enforce unique values in a column, excluding nulls?

I have a business requirement to have a FK field on TableA referencing TableB. If there is a value in TableBID, it should be unique, but it's not mandatory, so there could be multiple records with ...
1
vote
2answers
2k views

How to find DELETE and UPDATE statements that have been executed on a database?

I am trying to find out what delete and update statements have been executed on a certain database in a certain period of time. I came across this following query, but it generates an error message: ...
1
vote
1answer
205 views

Minimising downtime implementing merge replication on live system

Background We have three Servers running SQL Server 2008 which all contain a Product database. These are currently kept in sync once per day by sending a copy of the MDF to the two Subscribing ...
5
votes
1answer
4k views

Log Shipping - RESTORE WITH STANDBY - on SQL Server 2012 keeps breaking

We are using log shipping and RESTORE WITH STANDBY on SQL Server 2012 in order to restore the database in read-only mode for reporting purposes. However, the log shipping setup keeps breaking after ...
0
votes
1answer
738 views

SQL Server 2005 upgrade to Service Pack 4 (SP4) via command line

I have been wracking my brain over upgrading SQL Server 2005 to SQL Server 2005 SP4. I have a script for installing new instances of SQL Server for all versions and they all work wonderfully. Problem ...
1
vote
2answers
311 views

SQL Server 2005 upgrade service pack via command line

I have been wracking my brain over upgrading sql server 2005 to sql server 2005 sp4. I have a script for installing new instances of sql servers for all versions and they all work wonderfully. Problem ...
5
votes
1answer
1k views

Type conversion in expression may affect “CardinalityEstimate” in query plan choice?

I maintain an archive database that stores historical data in partitioned views. The partitioning column is a datetime. Each table under the view stores one month of data. We constraint the events on ...
3
votes
0answers
417 views

SQL Server Database Hot Backups: Which Technique(s) to Use for Multi-Level Replication?

I'm reading the many other posts here about mirroring vs. replication, but I'd still appreciate it if someone with some experience would weigh in. My small development team needs to have local ...
5
votes
2answers
1k views

Manually moving SQL instance to another node causes immediate database mirror failover

I have a two-node SQL cluster (2008 R2). Some of the databases within that SQL instance are mirrored to another server on a remote site, using the High safety with automatic failover. The mirroring ...
3
votes
2answers
512 views

Can I programmatically generate reports that are emailed as Excel docs from SSRS?

I've searched already and don't see (or can't decipher) a solution for my issue. I have SSRS emailing a report for 1 district (with 12 retail stores). However, each Region has over 8 Districts, and I ...
1
vote
0answers
53 views

Migration advice from SQL server 2000 bak

A small and old Windows 2003 server, just crashed; from the backup only the .bak files are available. A new server will be built, however, as the database is very small (20MB) and the Windows server ...
5
votes
3answers
3k views

Write differences between varchar and nvarchar

Currently in our SQL Server 2012 database, we're using varchar, and we'd like to change that nvarchar. I've generated a script to do that. My question is are there any differences in how SQL Server ...
2
votes
2answers
594 views

Check if row exists

I need to write a query that will insert a row only once, even if the query is run multiple times. Being new to SQL (well new-ish), I did an if not exists(...) but a friend said he preferred deleting ...
1
vote
1answer
540 views

Killing idle pooled connections

On SQL Server, I'm trying to prevent connection from staying open. From here I understand that Connection Lifetime allows a connection to stay alive for a certain period of time since it was opened. ...
0
votes
3answers
177 views

Select MaxDate where hh:mm:ss makes the difference

How to select the maximum date from a table where hh:mm:ss is selected? My query is the following, and returns the latest date, but if there are different times recorded, the date will be returned ...
6
votes
2answers
2k views

SQL Server alter table to change TEXT to NVARCHAR(MAX) greatly increasing database size

I need to update a SQL Server database thats about 18GB in size to change a significant number of TEXT columns to NVARCHAR(MAX). The problem I'm having is after executing all the alter table ...
3
votes
0answers
378 views

How do I get more details on a full text catalog error?

I have an error that is repeatedly generated on a SQL Server 2005 instance running the databases for MS Team Foundation Server. 'Severity 16' occurred on INSTANCENAME Looking in the SQL Server ...
1
vote
1answer
573 views

Optimizing an audit table for inserts and deletes

I'm trying to identify the best way to design a table for audit purposes. Basically I log several last events for many users in one table. There's a limit on the number of records for each user. The ...
3
votes
1answer
117 views

Creative workaround for granting edit rights to individual jobs for a group?

We have two developers that say they can not function without full rights to a few jobs on our database server. They both want rights to the same jobs. Given that it seems that MS doesn't seem to be ...
1
vote
1answer
5k views

How to fix “The OLE DB provider ”MSOLAP“ has not been registered”?

Here's the code I'm using to register a linked server to SSAS: USE [master]; GO EXEC master.dbo.sp_addlinkedserver @server = N'ServerAlias', @srvproduct = N'', @provider= N'MSOLAP', ...
4
votes
1answer
1k views

Join To a @Table Variable is running ineficiently

Alright so I have a report sproc that was running incredibly slow. Customers were complaining that the report would not run so I started investigating exactly where in the sproc the problem was and I ...
0
votes
2answers
1k views

Need a way to query a table, and JOIN it with the TOP 1 related record from an other table

As a follow up to this question, I'm wondering if there is a better and/or more efficient way to gather the data in question. As stated, this query does return me 95% of the data I need -- SELECT ...
0
votes
3answers
555 views

Fixing a query that returns failed job information

I' using a SQL Server 2008 Sp3 environment. I have a query that returns information about failed jobs from the last 10 minutes. If a job has two schedulers (for example - a job that runs every 10 ...
1
vote
1answer
197 views

Restoring a differential backup in SQL server 2005

I have created a full back up of my database by executing the line below in my application: Dim Query As String = "backup database Ari to disk='G:\Documents and Settings\i\Desktop\BKAR\" & ...
0
votes
1answer
255 views

Restoring a differential backup in SQL server 2005 [duplicate]

I have created a full back up of my database by executing the line below in my application: Dim Query As String = "backup database Ari to disk='G:\Documents and Settings\i\Desktop\BKAR\" & ...
0
votes
2answers
1k views

SQL Server 2008 R2 not starting after moving model database

SQL Server 2008 R2 not starting after moving model database. Any ideas? Error: 945, Severity: 14, State: 2. Any ideas? Sql 2008 R2 will not start with trace -f -T3608 or single user mode -m. Need ...
2
votes
2answers
945 views

Why do I need to use a sub query to filter down a grouped select?

If I do this -- SELECT dv.Name ,MAX(hb.[DateEntered]) as DE FROM [Devices] as dv INNER JOIN [Heartbeats] as hb ON hb.DeviceID = dv.ID WHERE DE < '2013-03-04' GROUP BY dv.Name ...
1
vote
1answer
4k views

Are “create user” and “grant connect” functionally equivalent?

I don't have a problem per se, but I've noticed that if I grant a database permission to a principal that doesn't exist in the database, the permission shows up in sys.database_permissions but that ...
1
vote
1answer
620 views

SQL Server Database Mail - Why can't I run an execute against xp_sysmail_activate?

SQL Server 2008 R2 Standard x64 I can't send e-mail from this SQL Server (out of MANY that are configured pretty much identically AFAIK). I have created the mail profile and account. However, any ...
4
votes
1answer
52 views

Can I query data_space names when not in context of the database for multiple databases?

I have a data set pulled from sys.master_files. The data set looks something like this: database_id filename physical_name data_space_id ----------- ---------------- ------------- ...
2
votes
2answers
180 views

Help with tricky update statement

I've tried writting this update statement every possible way I can think of but I either wind up producing invalid results or run into a syntax barrier. I have two table variables: DECLARE ...
-1
votes
1answer
578 views

FETCH API_CURSOR causing open transaction in tempDB

A select statement run from Oracle 11gR1 to SQL Server 2005 using Gateway leaves an open transaction in tempdb. The user is a datareader in Database XYZ. Not sure why the open tran is in tempDB when ...
2
votes
0answers
256 views

How to manage dynamic tables in Visual Studio 2010 Sql Server Database Projects

I am migrating a common set of databases in to a VS 2010 Sql Server Db project so we can keep it in source control, and deploy common changes etc. The databases are for the most part the same, except ...
2
votes
1answer
171 views

MDW performance_counter_instances table running out of identity values

My MDW database's performance_counter_instances table has run out of identity values. Has anyone ever encountered this? Is it safe to change the data type of the identity field ...
2
votes
1answer
170 views

Will a primary key be added as a clustered index?

I've inherited a database where no primary keys were defined on the tables. There are also no clustered indexes assigned to the tables. If I perform an alter table to assign a primary key will this ...
1
vote
1answer
381 views

SSMS Oracle import using OpenQuery over LinkedServer (Oracle Provider for OLEDB) - XML Parsing: unable to switch encoding

I am trying to migrate the data from an OracleDB to an SQL Server Express database. I'm doing this by openquerying a linked server (data provider based on Oracle Provider for OLEDB). Everything works ...