Tagged Questions

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
33 views

Export structure and data without a wizard [duplicate]

Using Sql Server 2008 R2 (but I could possibly upgrade if required). I want to generate scripts for the database structure as well as the data for a schema. The Generate Scripts wizard does what I ...
2
votes
1answer
24 views

Restore backup to different filegroup

Using Sql Server 2008R2. I have a backup of a filegroup. Is it possible to restore this to a different file group (possibly even on a different database)? I have tried RESTORE DATABASE my_database ...
1
vote
0answers
35 views

Foreign Key constraint remain untrusted and disabled even after ALTER TABLE CHECK CHECK CONSTRAINT command [closed]

In this database I support, there are more than a few FK constraints set as disabled or untrusted. I'm using this querys to find that out: SELECT 'ALTER TABLE [' + s.name + '].[' + o.name + '] WITH ...
3
votes
1answer
29 views

How to only restore a specific filegroup?

I am using SQL Server 2008R2 (but I can upgrade if necessary) I have a database with multiple schemas and each schema is on a different filegroup (I wish I could just backup/restore a schema but that ...
3
votes
0answers
52 views

ASSIGN value for cmd in sysprocesses? What does it mean?

We're seeing some strange blocking behaviour in a production (SQL Server 2008 R2) system that we're investigating, and it seems to have one consistent and novel element: in the sysprocesses table, the ...
3
votes
2answers
132 views

Can WAITFOR increase CXPACKET waits?

If I have some T-SQL code like this: While @done<1 Begin WAITFOR DELAY '00:00:30'; Set @done=<some select statement> End Is this likely to increase waits for CXPACKET? Presumably the other ...
1
vote
2answers
82 views

Separate data from 1 column into multiple columns

Below is sample data and expected results: Table1: salesprice ItemNo Variant SalesCode UnitPrice A 1 SRP 100 A 2 SRP 200 ...
1
vote
0answers
35 views

Log shipping option not showing

I am using SQL Server 2008 R2 Standard Edition. I am trying to implement log shipping, but the log shipping option is not showing in the database properties window. The database recovery option is ...
0
votes
1answer
38 views

Restore Database with Multiple Restore commands

For automation, I have to dynamically construct the restore commands and thus I have created a script. A .bak file is created on a remote server and I receive it daily. The script builds the restore ...
0
votes
0answers
13 views

SQLCMD.exe in SQL Server 2012 does not give real-time output logging [on hold]

I'm running a long-running stored procedure using sqlcmd.exe for automation purposes. However, I observed that in SQL Server 2012, sqlcmd.exe does not produce real-time logging. It displays only when ...
0
votes
2answers
71 views

Trying to return empty rows even if data does not exsist in SQL

I am trying to return the last changed time for a list of users, but i would like to return a row even if the a last changed time does not exist select user_id, last_changed_time = ...
0
votes
1answer
18 views

Replicating tables from LAN database to web server?

I have an in-house database (that's actually part of a third-party product) running on 2008R2 Express. We'd like to display some of the data on a new website we're working on (running 2008R2). I'm ...
-1
votes
1answer
61 views

How to aggregate related rows

I want to group these related rows into trips (where each trip consists of a sequence from point 1->2->3->2->1). route Date time ------------------------------- point1 15/10/2014 ...
2
votes
3answers
111 views

What is the most effective way to discover all running instances of SQL Server using PowerShell?

I've been tasked with discovering all the instances of SQL Server that are running within our domain. In several cases there are multiple instances per server. I've seen two different PowerShell ...
2
votes
2answers
40 views

SQL Insert Statement Persists Two Records When I Need Just One

I have altered it to include hardcoded variables when I pulled this chunk of code from the stored procedure. I ran it independent of the application with the same result. I need one insert statement ...
0
votes
1answer
20 views

SQL Insert Statement Persists Two Records When I Need Just One [duplicate]

I have altered it to include hardcoded variables when I pulled this chunk of code from the stored procedure. I ran it independent of the application with the same result. I need one insert statement ...
2
votes
0answers
89 views

SQL Server mirroring causing issues

So we have a couple of SQL Server instances involved on mirroring without witness and operating mode is asynchronous in all cases. After we set put mirroring in place, we started facing connections ...
2
votes
2answers
220 views

How to use local variable in USE statement

How to use local variable in USE statement? I get error: Msg 911, Level 16, State 1, Line 6 Database 'DWSource_@Country' does not exist. Make sure that the name is entered correctly. Code: ...
1
vote
1answer
73 views

sql server service broker

For the last few days the service broker command which run from master database is consuming much more RESOURCES than before. The Impact on the Database is high (from the bad side), It causes for ...
1
vote
1answer
47 views

TempDB not selectable for DBCC maintenance plan

I'm trying to clean up some of our maintenance plans and noticed that our TempDB is not getting it's weekly dose of DBCC CHECKDB goodness. I've tried to go into the maintenance plan and make sure ...
2
votes
3answers
232 views

Run multiple stored procedures in sequence

I have a stored procedure written in T-SQL (SQL Server 2008 R2). It is a master procedure that essentially call multiple other subprocedures in sequence. The call and error handling is identical for ...
1
vote
3answers
104 views

Tracking Down Application Timeout Errors in SQL Server

SQL Server 2008 SP3 How do I track down these timeout errors ? The errors are displayed on an intranet dashboard used specifically for error reporting in IIS. My suspicion is that there is a ...
0
votes
0answers
22 views

Sql server 2012 log file growth of cdc enbled db

All, I have cdc enabled on a Sql Server 2012 database that is a primary db in transactional replication and the primary in a availability group. The log file is a little over 95 GB, a historic high. I ...
1
vote
3answers
79 views

Deploying SQL Server database changes from test to production server

I have a high availability production server that runs SQL Server. It is constantly being read/write to by hundreds of users. I have an exact copy of the database on a testing server and do all the ...
1
vote
1answer
67 views

Unable to restore database

I am trying to restore several databases and I have no clue why some of them fail with the following error: Msg 3634, Level 16, State 1, Line 1 The operating system returned the error '1244(The ...
1
vote
2answers
54 views

Indexed views on double linked server

A server SERVER_A has some data. A server SERVER_B defines A as a linked server, and defines some views on the data. The queries are like this: CREATE view myview as select * from openquery ( ...
0
votes
4answers
64 views

SQL Server combine Update and Delete

Is it possible to combine both update and delete in a single SQL statement? I would like to execute something like this: update a set a.value = a.value + b.value from Table1 a join Table2 b on a.ID = ...
1
vote
2answers
39 views

MS SQL Server 2012 Log Shipping Questions

I have a few questions regarding Log Shipping in SQL Server 2012. 1) If the primary database server dies, is it possible to allow users to connect to the secondary database so as to continue working ...
3
votes
2answers
102 views

Insert only deadlocks

We have an application inserting data into a table. Unfortunately, we are getting deadlocks and the deadlocks are coming from inserts only. We are seeing the inserts take key locks in a different ...
0
votes
0answers
42 views

Problem in Incorporating filters into Data Warehouse design

While implementing a data warehouse (proof of concept) I have a requirement to incorporate a user level save-able filter on dimensions. The requirement is a proof of concept so I have the liberty to ...
1
vote
1answer
58 views

“Could not insert a backup or restore history/detail record in the msdb database” While restoring msdb

Today I found msdb database was in suspected mode, so I restored MSDB from my latest backup(As I have daily backup for this database). When I restore the MSDB database using Tsql i got below errors, ...
3
votes
2answers
510 views

Which of the following pieces of SQL is most efficient

I need to add the date part of GetDate() to the time part of a stored DateTime. Naively I thought I could do the following: declare @testTime DateTime = '2013-04-23 13:55:06' select cast(getdate() ...
0
votes
2answers
51 views

Live Partial Table / column replication

I want to know if there is a way to achieve the following with SQL Server 2012 Enterprise Edition? I have Table A: on Server 1 with say 10 columns. Table A: | col1 | col2 | col3 | coln | col10 | ...
5
votes
2answers
73 views

Is the runtime of checking for duplicate primary keys in SQL Server O(n)?

I was curious and I couldn't find too much info on this. Is it also O(n) for checking for duplicates among primary keys? Is it the same for most other SQL databases? Is there a place that lists this ...
5
votes
1answer
86 views

SQL Server stuck in single_user with auto_update_statistics_async on [closed]

Books online states Before you set the database to SINGLE_USER, verify the AUTO_UPDATE_STATISTICS_ASYNC option is set to OFF. When set to ON, the background thread used to update statistics ...
0
votes
2answers
39 views

Find field that was changed

I have database with log backup every 15 minutes. I believe some data in one table was changed 10 hours ago. Is there any way I can find that query and located changed/updated data in log backup ...
0
votes
0answers
65 views

Problem with EXEC MyLinkedServer…sp_executesql within transaction

I rather clueless about this so any help is appreciated. We have got a stored procedure that is running within a transaction. The stored procedure is called from a .NET program (via normal ADO.NET). ...
0
votes
1answer
52 views

Working out Duplicated Data in a Customer Data Base

I have a database in SQL2008 of customers, There is an ID number for the customer. What im trying to do is to create a NEWID field. We have duplicated customers that have different ID fields, I am ...
0
votes
0answers
61 views

Window function sorting performance

For background, I am on an instance of SQL Server 2012 Enterprise Edition. I have three tables that join on the same set of three keys - all of them are INT. All tables have their keys clustered in ...
1
vote
1answer
126 views

What's the term that describes filtering query that makes use of indexes

I am looking for a technical term that describes the type of query in SQL that makes use of indexes. I completely forgot the name and can not look it up anymore (there's even a Wikipedia article about ...
0
votes
1answer
35 views

Automatic change of “initial size” of a database?

I just had a problem : days ago, on one of my client's databases, the LDF file suddenly grew up to 100% of the disk capacity. .TRN backups are correctly done every 15min (I don't think reducing this ...
2
votes
1answer
40 views

Restore database with different filename

I have to restore a new back up file daily (as an agent job, after first deleting the existing db) but the file name will vary as it will include the timestamp as well. How can I achieve this so ...
2
votes
3answers
82 views

How do I kill a rollback process when I want to drop the database?

I want to drop a SQL Server 2008 database, but it is currently performing a rollback for a transaction (that transaction took 3 days to run so far). How do I stop the rollback because I want to drop ...
0
votes
1answer
72 views

Best approach to have a Live copy of a table in the same database

I have a table where 15,000 to 20,000 rows are being inserted every hour. Table Schema is something like ColumnName DataType ID BIGINT IDENTITY(1,1) Column1 INT Column2 INT ...
5
votes
2answers
281 views

Terrible Bad Query Plan

I have a weird query plan problem. I have two databases (Let's call them DB1 and DB2) where both are sitting in the same SQL-Server instance and have identical schema. In there, we have a couple ...
0
votes
1answer
64 views

Select children from hierarchy (/a/b/c/d/)

I have to select from database which I did not create and I have this problem: example schema: Unit ---- id HierarchyPath (example: '/42/48/63/84/') UnitName (example1: "John" example2: "Team1") ...
1
vote
1answer
36 views

Minimum SQL Server rights that allow viewing column default values

I have an SQL Server 2008 database, some of the fields (columns) in some of the tables are configured with default values. I have a requirement to limit user security as much as possible, ideally ...
3
votes
1answer
47 views

How to join by most recent preceding date?

Imagine I have a database with historic price data and a second table with dates Item | Price | Date Customer | Item | date ------------------------- --------------------------- ...
1
vote
3answers
71 views

How to run sql agent jobs in a sequence order.with T-sql

My requirement is to run the SQL Agent jobs (EX: job1 to job10) with T-sql in a sequence order. That means job2 starts automatically when job1 completes. This process should continue until job10 ...
1
vote
0answers
47 views

The replication Merge Agent failed to propagate a Publisher schema change to the Subscriber

We are running 2 Microsoft SQL Servers - publisher (2008R2) / subscriber (2008 Express) with merge replication. I tried to make some schema changes via Transact-SQL and partly failed. So tried to ...