All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag like sql-server-2016 if that is relevant to the question.

learn more… | top users | synonyms (2)

6
votes
1answer
660 views

SQL Server: Unable to save import export package, but am on Standard Edition

I am confused. Issue: SSIS ("SQL Server Import Export Wizard") should let me build a data import package and save it to a file, for easy re-running (converting to a task, etc.). I want to save a ...
3
votes
1answer
241 views

What is the relationship between the SSIS Package Store and Catalog?

I have a server with a working installation of the Sql Server 2012 SSIS Catalog. I need to set up an additional instance including the SSIS Package Store service as an interim step while the packages ...
1
vote
1answer
103 views

Most efficient table storage for determining recurrence

What is the most optimal table structure to store schedules / recurrence definitions so that we can efficiently query it for all events that will occur within a date range (min:1 max:32 days)? My ...
1
vote
0answers
89 views

SQL Server tool for merging rows [closed]

We have a SQL Sever 2008 database that occasionally receives bad data from customers. The issue we are trying to address here is that sometimes duplicate records are created where one row has some of ...
2
votes
1answer
704 views

Process Data cube from job on SQL server

I have an SQL Server Agent job on server(X) that has a step that is supposed to process a data cube on a remote server(Y). Whenever I run the job it fails and says that server(X) does not have ...
3
votes
1answer
61 views

Determine Gap Records, Fill and Return Result

The following working code targets SQL-Server 2012 and I have distilled the actual problem into a manageable scenario with the code example shown below also presented on SQL Fiddle. I seek feedback ...
0
votes
0answers
45 views

Refactoring 80 GB table that stores massive amount of calculated results

Trying to evaluate architectural changes to improve the performance of an app that calculates a lot of individual values and stores each of these results as a row. The storage size for one of the ...
1
vote
1answer
78 views

Best way to back up data bases on a SQL Server Availability Group DR Site node

I have an Availability Group (Primary only is readable) with 2 nodes locally and 1 node at a DR site. Both sites have a backup system. Locally, I’m using the local backup system to back up the AG ...
3
votes
2answers
374 views

Historical dbcc checkdb results

Is there a better way of accessing historical dbcc checkdb result history (if output logging was not used at runtime) than xp_readErrorLog? EXEC xp_readErrorLog {0-20}, 1, N'CHECKDB'; SQL Server ...
2
votes
0answers
38 views

SQL Server database suspect

All the databases went to suspect mode on a server. Tried bringing on-line by taking emergency but did not workout . Have restarted the server as there is disk I/o error still in suspect mode. Can ...
1
vote
0answers
299 views

Could not redo log record on mirror

One of my database mirrors is in the suspended state today and the error log on the mirror shows the following. Could not redo log record (338934:102862:477), for transaction ID (0:848150408), ...
-1
votes
1answer
68 views

Insert id into another table and give the item another id that is autocrementing?

Need this answered if anyone can help. I need to create a query that will automatically insert ordID, but give it a new auto incremented OrderNumber in Orders.dbo. Fiddle is below: http://sqlfiddle....
0
votes
0answers
96 views

Shrink database or DB files not reducing size even after dropping biggest table

Our MDF file was originally 550GB in size (log is just 10MB), and the biggest table we had [HourlyCounters] was 140 million rows with 580 columns (varchar[50]). It's a table with a very inefficient ...
1
vote
1answer
100 views

Proxy for MDW data collection on remote servers - SQL Server 2012

I am trying to setup data collection (for disk usage) from remote servers and upload it to my MDW database. I understand I will need a proxy set up for the agent to do this but which subsystem to I ...
7
votes
4answers
25k views

Convert date yyyy-mm-dd to integer YYYYMM

How can I convert @dateb: SET @dateb = dateadd(month, datediff(month, 0, getdate()) - 3, 0) that returns 2014-04-04 as date to an integer of 201404 Thanks
0
votes
0answers
33 views

Shrink database or DB files not reducing size although I dropped biggest table

Our MDF file was originally 580GB in size, and the biggest table we had [HourlyCounters] was 140 million rows with 580 columns (varchar[50]). It's a table with a very inefficient schema, but there's ...
0
votes
0answers
17 views

Hide table object from db_datareaders

Is there a way to grant select on a view without having to grant select on the underlying table object too? Problem is: 2 users share the same table. Both currently have db_datareader privileges. ...
1
vote
1answer
50 views

Attach Database is disabled in Microsoft SQL Server 2012 Management Studio

I have buy from Godadday hosting and domain, after that I have create database in godaddy and the connect to this db using my authentication. I have .mdf, .ldf that need to attach to the connected ...
4
votes
1answer
110 views

Limiting Domain Admins permissions on a SQL Server

I have a SQL Server 2012 machine and I want to limit the Domain Admins permissions. What can I do to make sure that the Domain Admins have read only permissions for the databases and nothing else for ...
0
votes
1answer
152 views

Failed SQL Login - Source server same as destination cannot locate SPID SQL Server 2014

Bit of a confusing one here. We are getting repeated messages in the SQL Server error log as below for a SQL Server instance: NT AUTHORITY\SYSTEM Reason: Failed to open the explicitly specified ...
0
votes
1answer
73 views

SQL Server transactional replication issue with database

We have on the server a database and we want to replicate a database on another server. we've set a transactional replication, but we have issues with the default constraints on the tables: On the ...
0
votes
2answers
169 views

Auto increment a value using cursor in SQLServer

I am developing an employee leave management system and My table structure with data is : +-----------+---------+----------+----------+------------+--------------+ | EmpID | CL | PL | ...
2
votes
2answers
3k views

Pass parameters to a procedure with SQLcmd

I use this SQL command: sqlcmd -v first_date="30/09/2015" last_date="15/09/2016" And I would like to pass that parameters to a stored procedure: ALTER PROCEDURE [dbo].[_testProcedure] WITH ...
2
votes
3answers
162 views

SOS_Scheduler_Yield wait type

I am having a process that has a last_wait_type as SOS_Scheduler_Yield and is inserting 100 records to a table. This process has been with this wait type forever with low CPU utilization %. There are ...
3
votes
1answer
233 views

How to create a login and user that can only access one schema in one database

I have executed the following: USE [MyDatabase]; GO CREATE LOGIN [MyDomain\MyAccount] FROM WINDOWS WITH DEFAULT_DATABASE=[MyDatabase]; CREATE USER [MyDomain\MyAccount] FOR LOGIN [MyDomain\MyAccount]; ...
3
votes
2answers
85 views

Applying GROUP BY when using multiple CASE WHEN

select e_id ,CASE WHEN w_id in ('1','2') THEN w_id ELSE 0 END as new_w_id ,CASE WHEN w_id = 1 THEN fee END as value1 ,CASE WHEN w_id = 2 THEN fee END as value2 ,CASE WHEN w_id not in ('1','2') THEN ...
1
vote
0answers
40 views

Endpoint acting as a mirror and witness?

Let's say I have 4 SQLServer 2012 R2 divided into two mirrors: SQL1-1 with its mirror SQL1-2. The Witness is SQL2-2. SQL2-1 with its mirror SQL2-2. The Witness is SQL1-2. The mirorring has been ...
4
votes
2answers
145 views

How to backup MS SQL Server databases off-site?

Microsoft SQL Server supports backing up to remote network locations only by means of UNC names the SQL Server (and user account it's running under) has access to. Is it possible to create backups ...
1
vote
2answers
141 views

SQL Server 2012 and DBM

Why would MSFT would deprecate mirroring from 2012.. I understand alwaysON will replace it but then SE users are left with nothing..no alwaysON or dbm from future releases.. Just analyzing from end ...
0
votes
1answer
191 views

SQL Server: INSERT in transaction locks the table until transaction finished

The sample VB.Net code below gets stuck and times out at the first read operation on CMD2. That seems to contradict the top ranked answer to question 6374. If that answer was correct, what can help ...
5
votes
1answer
566 views

existing foreign key that references fields with different datatype (char(8) and varchar(8))

This is more a quest for information that a request for help... I'm upgrading some old databases (running on sql 2005 and compatibility level 70, I suspect they are online since sql 6.5) to get rid ...
7
votes
4answers
2k views

How can I convert a key in a SQL Server deadlock report to the value?

I have a deadlock report that tells me that there was a conflict involving waitresource="KEY: 9:72057632651542528 (543066506c7c)" and I can see this: <keylock hobtid="72057632651542528" dbid="9" ...
1
vote
1answer
394 views

select query on Temp table is not returning data in correct order even after specifying index hint [duplicate]

In my code, I am creating a temp table using select * into #tempTable. Temp table contains the huge number of records and I need to retrieve data from it many times in my code so I created a ...
2
votes
3answers
908 views

Using variable for database name

I am having difficulty in using a variable name for the database. The below script searches through all databases and finds database that match a certain condition. The matching databases are added to ...
0
votes
1answer
38 views

Deploying Shared MS Access DB — Summer Intern first time with Access

So to give a brief background I've got a summer internship and was asked to modify and add features to an already existing MS Access DB. I don't actually take databases until next semester, so I was ...
4
votes
1answer
185 views

Do multiple SQL Server instances increase security?

Context Let's assume you have a server which exposes a web server and one or more web services to store and manage sensible information about physical persons (assume, for this example, complete ...
1
vote
1answer
145 views

SQL Server full text search query takes way too long to execute

I've got query snippet as follows: SELECT * FROM CONTAINSTABLE(dbo.Analysis, *, 'FORMSOF(FREETEXT, "historic year-on-year exchange rates forecast year-on-year exchange rates")'); I'm running it on ...
6
votes
1answer
2k views

The curious case of HADR_SYNC_COMMIT waits

We are noticing an interesting pattern for HADR_SYNC_COMMIT waits in our environment. We have a three replica; one primary, one sync secondary and one async secondary in a datacenter and we just added ...
2
votes
1answer
174 views

Powershell - SQL Server - connectionstring in loop for multiple Instances

Thisis part of a bigger script which finds DatabaseFiles on a SQL Server machine (multiple instances). Following should just return all files for 3 instances. The server is called V3000801 and ...
2
votes
1answer
40 views

Managing the Service accounts in large environment

I wanted to know if there's a best practice in regards to secure a large environment of SQL Server instances (version 2000-2012). Currently the SQL services are running with many users and I'm trying ...
2
votes
1answer
266 views

What are the best practices for restricting write-access on a specific table?

I have a table, which I'd like to be read-only, except for a few specific stored procedures which need permissions to UPDATE rows in the table. After that, I want only a select group of additional ...
1
vote
1answer
27 views

SSRS in database server

Is it advised to use SSRS in the database server itself? Will it hamper the performance of the server itself. (in SQL SERVER 2005) What are the merits and demrits of the same?
0
votes
0answers
17 views

Options for reducing transaction log size when disk space is restricted [duplicate]

I have a very unfortunate situation in which I have some SQL Server (standard edition) databases living on a small (~120gb) disk, and a transaction log which has grown to 50gb+. Unfortunately, the ...
0
votes
1answer
34 views

How can SQL server AlwaysOn AG can be used as a DR feature?

I'm using AlwaysOn ag feature as a HA feature where automatic failover is possible.. I was thinking to log shipping as DR but there is potential data loss in that.. thinking of using ag as a dr(async)....
6
votes
1answer
423 views

No service broker active on database

I am trying to set up query notification however when I try to create a queue and service I get the error 'There is no Service Broker active in the database. Change to a database context that contains ...
1
vote
1answer
116 views

Is it ok to create additional column for helping other column to be a PK?

Let's say a Person can have more than one nickname. He(she) must enter his(her) nicknames alongside with other details: Here is the table columns: User_Id, Nickame, Age Of course, for now there ...
4
votes
1answer
97 views

Query Notification setup

I am relatively new at playing around with this and have been trying to follow a tutorial on setting up in the section named "Prerequisites to Create SQL Notification Requests" within this site http://...
15
votes
1answer
495 views

Query strategies using SQL Server 2016 system-versioned temporal tables for Slowly-Changing Dimensions

When using a system-versioned temporal table (new in SQL Server 2016), what are the query authoring and performance implications when this feature is used to handle Slowly Changing Dimensions in a ...
2
votes
0answers
76 views

SQL Server 2012 replication setup on routed network

I'm trying to setup replication between two SQL Server 2012 instances. I set up a publication successfully on server1, but then I had a problem when trying to access it from server2, because the only ...
2
votes
1answer
104 views

Query takes longer as domain user than local admin

I have an application that runs ad-hoc queries to a remote SQL server. I'm running into a bizarre problem with the application taking significantly longer to return results when the application is ...