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
1answer
2k views

ORDER BY items must appear in the select list […]

Using Microsoft SQL Server 2008, I get the following error. Msg 104, Level 16, State 1, Line 43 ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or ...
1
vote
1answer
21 views

New instance with same @@VERSION as existing instances

I have a SQL Server 2008 R2 server with several instances installed. Is there a way to add a new instance and have it be to the same build as the existing (and updated / patched) instances?
7
votes
6answers
4k views

.bak file not visible in any directory in SSMS

I have a .bak file created today by someone else, manually created through SSMS 2008 R2. I'm trying to manually restore the database, unfortunately the file isn't appearing when I go to browse it. I ...
9
votes
2answers
780 views

DBCC CHECKDB unfixable corruption: Indexed view contains rows that were not produced by the view definition

TL;DR: I've got an unfixable corruption in an indexed view. Here the details: Running DBCC CHECKDB([DbName]) WITH EXTENDED_LOGICAL_CHECKS, DATA_PURITY, NO_INFOMSGS, ALL_ERRORMSGS on one of my ...
9
votes
2answers
2k views

When does sp_executesql refresh the query plan?

You'll have to forgive my naivety as I'm not a DBA but my understanding is that over time the statistics of a database change and a stored procedure must be recompiled to keep the query plan up to ...
1
vote
1answer
50 views

How to distinguish the current operation is done from system or from sql server management studio

We want to record who insert or update the records in sql server database, so we add "CreatedBy" and "ModifiedBy" fields. When the records is operated from the system, we can easily get the person. ...
6
votes
2answers
421 views

SQL Server Tuning a table for massive inserts

I'm trying to solve a performance issue and I need advice. I have a table, which about twice a day has a massive surge of inserts coming in, and exactly at the same time everybody is trying to read ...
0
votes
2answers
221 views

Full text catalog does not allow me to hit on singular forms

I have created a full text catalog for a column under database name -> "Storage" -> Full Text Catalogs. It is accent sensitive and "default catalog" is set to false. The language for the column ...
2
votes
3answers
5k views

overwrite table with data from another table - SQL

Our users want to refresh a QA database from production but want two tables (lets call them T1 and T2) to retain the original QA data. So I copied two tables from QA (DB1) to a temp QA database (DB2). ...
0
votes
1answer
44 views

Apply profiler template to saved log

I need to check for deadlocks in my customer's system. He provided me with unfiltered logs. Can I filter them after running the trace somehow? (I don't have direct access to his server) It seems ...
4
votes
1answer
4k views

Importing a large column (8000 chars) from Excel using SSIS

I'm trying to set up a regular import of an excel spreadsheet that we get from a vendor. I'm using SQL 2008 R2 SSIS to import it into a table. The problem connection manager is an OLE DB connection ...
1
vote
2answers
198 views

How to avoid timeouts during big DML operations

I have a big insert script I need to run. Its about 55,000 records and 160 columns. The script is already created and I can't create it again. The problem I have is that this runs for about 4 hours ...
10
votes
2answers
6k views

Need to understand parallel query execution error

Today we experienced a degradation in performance on our production sql server. Durring the time this occurred we logged several "The query processor could not start the necessary thread resources ...
3
votes
1answer
2k views

Cannot rename the table because it is published for replication

I need to rename some tables in my DB - SQL Server 2005, with this: EXEC sp_rename 'dbo.TableName', 'Tmp_TableName', 'OBJECT' but I can't do this - I get this exception - Cannot rename the ...
2
votes
1answer
278 views

Is the Service Broker good for publishing data between servers?

I'm trying to find a better solution when publishing data to a remote table. So we have Server A and Server B. Server A holds a master table which should be replicated to Server B. Currently, we ...
2
votes
0answers
192 views

always on availability group with different speed disks

I'm looking to set up SQL Server 2012 installation with an Always On Availability Group, where the 'passive' replica will be hosted at another site on the WAN and using synchronous data commit - the ...
3
votes
4answers
3k views

Cannot remove unused filegroups

I wanted to remove some unused filegroups/files in a SQL Server Database but am stuck because SQL Server thinks the filegroups/files are still in use. Some background: We had some partioned tables ...
0
votes
1answer
383 views

Full text query slow on first run [closed]

I have SQL Server database which has size of 65GB and 6 million rows. We have essays in tables and the average size of an essay is 450 words. When I run a query for the first time, it takes 3-10 ...
3
votes
1answer
319 views

Splitting different parts of a string

I have an SQL Server database where there is a cell with a delimiter (\) separated string. An example of this string would be: category_path ============= RootCategory\Middle Category\Child ...
4
votes
1answer
5k views

SQL Server Maximum and Minimum memory configuration

What are the correct settings for min-memory and max-memory in this use case? The server has 8GB ram, dual Intel Xeon processors, running Windows Server 2008 R2 / Sql Server 2008 Standard Edition. ...
2
votes
0answers
269 views

A Tool to Manage Tracking Query Performance Improvements [duplicate]

I'm building a BI system on SQL Server 2012. I have a test set of data with some tens of millions of rows. Currently many functions and stored procedures are unacceptably slow. I'm looking for a tool ...
1
vote
3answers
861 views

How can I drop a stored procedure whose name is in a variable?

Given a variable that contains a stored procedure name: DECLARE @stored_procedure_name sysname; SET @stored_procedure_name = 'some_stored_procedure_name'; How can I drop the stored procedure?
2
votes
1answer
4k views

Why is my Amazon RDS instance so slow?

I currently run a Windows Server with SQL Server Express. I'd like follow best practice and separate the application from the database, so I've created an RDS instance and exported my database. ...
2
votes
1answer
3k views

Can not find 'NT AUTHORITY\NETWORK SERVICE'. on Sql Server 2012

Hi How do i fix this Error? when i run my MVC app i get this error though my web.config is find. the error is on my DB call Sample: Cannot open database "Sample" requested by the login. The login ...
1
vote
2answers
975 views

Updating a table efficiently using JOIN

I have a table that has the details of households and another that has the details of all the persons associated with the households. For the household table I have a primary key defined using two ...
1
vote
3answers
1k views

Restore database - maintenance plan task

I need to schedule a task that restores a database once a week from a backup. I have setup maintenance plans for backing up databases (Management > Maintenance Plans) but cannot find out how to make a ...
2
votes
2answers
388 views

Workaround for Anti-Semi Join bug

I built the following SQL Server query, but it is encountering the anti-semi join defect in SQL Server 2005 which results in inaccurate cardinality estimates (1 -- urgh!) and runs forever. Since it is ...
4
votes
1answer
400 views

Understanding MS SQL Server Date Types

Consider the following: declare @dt datetime, @dt2 datetime2, @d date set @dt = '2013-01-01' set @dt2 = '2013-01-01' set @d = '2013-01-01' select convert(varbinary, @dt) as dt, ...
1
vote
0answers
133 views

Optimising Large SQL Server Tables [closed]

I have a large table with around 50 million rows and 15 columns. Whenever I read, I always need all columns so I can't split them. I have a clustered index on the table with 4 keys (ALL INT) and I ...
10
votes
1answer
2k views

AlwaysOn AG, DTC with failover

Problem: How can I run Distributed Transaction Coordinator (DTC) on all servers in an AlwaysOn Availability Group (AG)? I do NOT need to maintain transactions over failover/switchover events. Setup: ...
1
vote
2answers
2k views

How can I “shift” certain column values to different rows in an existing table?

I'm implementing a queue as a ring buffer in a table along the lines of what Thomas Kejser talks about here: Implementing Message Queues in Relational Databases If the ring buffer fills up, I have to ...
1
vote
2answers
3k views

How to make SQL Server Management Studio use latest version of SQL Server?

I'm upgrading my dev machine from Windows 7 to 8. While installing earlier versions of Visual Studio it installed SQL Server 2005. I then went to this site and downloaded and installed SQL Server ...
5
votes
1answer
317 views

How to get output from trigger on linked server

Fair warning, I know this isn't the best way to do this, but I'm trying to extend some existing code without needing to do a rewrite. Anyway, I've got two SQL Server 2012 installs, one local in my ...
0
votes
3answers
253 views

Sql Server 2012 Restoring Master and Migrating a server

I am migrating an entire Sql Server instance with 10 databases on it. It has many sql jobs and users. What is best practice regarding the master database? Should I backup and restore this too, or ...
1
vote
1answer
115 views

Number of times a table is read, written to and updated

Is there a way I can find out the number of times a table is read, updated, added to or has had rows deleted during a trace? I am creating the trace in SQL using sp_trace_setstatus, not using the Sql ...
2
votes
1answer
68 views

Logging and Replaying database updates/inserts SQL Server 2008

I am in the process of migrating our client's database to the Azure Cloud SQL Server and setting up data sync etc. All of this is ok, but I need to reduce the amount of time the client's system needs ...
6
votes
2answers
6k views

How can I see the current Database Mail configuration?

Our SQL Server (2008) instance is configured to send mail and everything is working correctly, but I can't figure out how to view the existing configuration, in particular the SMTP server. From SSMS ...
-4
votes
1answer
165 views

SQL Server 2012 having two database in the same server but different Hard drives [closed]

I am quite new in terms of SQL Server. I tried to search but can't really find any topic related on what I asked, or probably I didn't phrase my search term correctly. Here is what I am trying to ...
6
votes
5answers
2k views

SQL server level permissions

I am aware of the Microsoft provided code to transfer logins between SQL servers, however this only does the account and the password. What if that particular account has various roles and ...
3
votes
1answer
176 views

Forwarded Records, effective way to fix them

I'm dealing with an issue in SQL Server databases of an application. This application is used for Healthcare and I only maintain the databases, I do not create the application. Clients are facing the ...
13
votes
4answers
3k views

Identifying Unused Stored Procedures

This next year, I am helping an effort to clean several SQL Server environments. We have about 10,000 stored procedures and estimate that only about 1000 of them are used on a regular basis, and ...
0
votes
2answers
108 views

Replicate to a secondary database that also allows edits

I have a client with a somewhat odd requirement. They want to be able to take a snapshot of their sales database that their accountants can then use once it's disconnected from the live database. That ...
3
votes
2answers
498 views

Replacing master.dbo.sysperfinfo with sys.dm_os_performance_counters

I'm working with some old code that pulls performance counters, and part of what I'm doing is making sure we're doing some processes efficiently and effectively. Right now I have this code that I'm ...
1
vote
1answer
52 views

Foreign Key off of a UNIONed View

I have a view that looks like this: CREATE view reference.Test WITH SCHEMABINDING as SELECT reference.HighlevelTestId as TestId, Name, IsActive, cast(1 as bit) as ...
1
vote
1answer
444 views

MS SQL Server 2005 DB backup with partitioned tables to non-partitioned SQL Server 2012

I have a database with several partitioned tables on MS SQL Server 2005 Enterprise, and I have to restore this DB on MS SQL Server 2012 Standard. Since Standard doesn't support partitioning - it's a ...
2
votes
1answer
85 views

Which Edition Of SQL Server Is On The Disc? [duplicate]

I have several SQL Server 2008 R2 setup discs, but they're not labelled with which edition (Standard, Developer, Enterprise etc.) they are for. Running them doesn't give much help as it just shows ...
2
votes
2answers
1k views

How can I execute a stored procedure whose name is in a variable?

Given a variable that contains a stored procedure name: DECLARE @stored_procedure_name varchar(512); SET @stored_procedure_name = 'some_stored_procedure_name'; How can I execute the stored ...
4
votes
3answers
162 views

Expanding a dataset based on a weight field

I have a table that contains records in an un-expanded form. Each record has an associated integer weight that essentially informs us how many times the record should be replicated in order to get the ...
-2
votes
1answer
236 views

Query sql-server db and insert results into PostgreSQL

I have a query that returns data from sql-server and I need to be able to put the results into PostgreSQL. I'm using C# for the task.
3
votes
2answers
6k views

Are there any third party tools that can read and/or analyze SQL Profiler trace (.trc) files [closed]

I have a .trc file from a trace that a DBA did on one of my databases. I don't have the SQL profiler tool installed on my PC so I can't view the contents and analyze the trace log. Are there any third ...