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)

2
votes
1answer
131 views

How can I speed up a stored procedure?

Here is an interview question I just had. I would like to know what a good answer to this would have been and what the different options would be. We have a stored procedure that is taking 26 ...
0
votes
1answer
30 views

Restore a database with compression on a non-enterprise edition SQL Server

Is it possible to restore a compressed an object from backup without the Enterprise Edition? I'm getting the following error after a RESTORE DATABASE operation. Msg 3013, Level 16, State 1, Line 2 ...
2
votes
2answers
59 views

Completion of SQL Job triggers start of job on a different SQL Server

I want the completion of a SQL Server agent job to trigger the start of a job on another server. More specifically, I want my SSRS server to email a subscription report whenever an FTP/Import job ...
0
votes
0answers
22 views

SQL Server Job does not execute when scheduled, but does execute manually, how do I get it to run as scheduled? [duplicate]

I am running SQL Server 2014 SP 1 CU 5. The job did work in the past. The schedule is enabled. The account it is running under is an ADS account which has sysadmin rights and has delete rights to the ...
0
votes
1answer
42 views

Same query same data different server different query plan

I have a query that hits a view, which references other views etc...several levels down. The query plan is a bit complex. I run the query on 2 different servers. On both servers, the number of rows ...
3
votes
2answers
49 views

Define a proper index for a table

I have a table with millions of rows and something like 20 columns. This table have an unique identifier as primary key, but the most likely query is based on three varchar columns (col1 and col2 of ...
5
votes
1answer
483 views

Does a single rollback affect all transactions?

When I run the following script: begin transaction select XACT_STATE() select @@TRANCOUNT begin transaction select XACT_STATE() select @@TRANCOUNT begin transaction ...
0
votes
2answers
34 views

How to separate values from one column into two columns in SQL Server [closed]

I have this dataset as input: Name Contact No ------- ---------- Deepika 75865558 Deepika 207586558 Rnveer 746655558 Rnveer 946655558 vaibhav 2356841 vaibhav 6655558 I want to get ...
0
votes
0answers
21 views

Can't connect to Database in Network using MS SQL 2016

I'm completely new to MS SQL Server and trying to connect to a Database in my network. I can find it, but everytime I am trying to connect it says username or password would be wrong. What I have ...
-1
votes
0answers
27 views

How to configure table with BLOBS (type image)?

I am about to overwork a table storing BLOBs in an IMAGE column combined with those file's metadata during a database maintenance. Lot's of the BLOBS will be removed during this process. We are ...
0
votes
0answers
10 views

Is this work flow suitable for Amazon RDS?

I am considering to set up a MySQL database via amazon web services (AWS). Consider the following steps which characterize my workflow: There is a daily data inflow into several AWS EC2 instances On ...
1
vote
1answer
28 views

Constraint column value based on another column? SQL Server

i am trying to set my defaults column Y or N based on membershipType column. There can be only one Y in defaults column based on the 3 different value in membershipType column. Other than that, others ...
1
vote
2answers
30 views

SQL Server — More efficient alternatives to repeating an (almost) identical subquery

I need to improve the efficiency of multiple subqueries within a WHERE clause. The context is a report generator on an existing product. The only input I can provide is the WHERE clause. I have 3 ...
-1
votes
1answer
19 views

Data Quality Service (DQS) and Master Data Services (MDS) [closed]

Best practice question. Is anyone using one of these in production? Can you share your experience and the business need you were solving with it? I am learning about them and do not really see the ...
0
votes
0answers
23 views

Querying Special Characters in SQL server

A MS Access user is trying to query a table with special characters in certain columns. The symbols show fine in the DB with default collation, whereas they show differently in non default collation. ...
0
votes
1answer
60 views

Query for a single unique record takes about 1.5 seconds

I have a simple table with a 13 byte unique key (indexed unique, non-clustered) and about 6 other small fields of no more than 10 bytes each. The table has about 8 million records. I have rebuilt the ...
1
vote
0answers
23 views

Powershell Invoke-Sqlcmd Implicit Transaction

Does Powershell, through invoke-sqlcmd or through running a query directly through a cmdlet, wrap a query in an implicit transaction? And if so, is there a way to work around this should my query ...
2
votes
1answer
38 views

Search for X at the beginning of a line within a multi-line string

On SQL Server (2008), I have a column which is varchar(max). I want to query for all rows where the blurb contains a lettered list: Some sentence is here a. foo b. bar c. baz Some more text later ...
-1
votes
0answers
41 views

SQL Server Job does not execute when scheduled, but does execute manually [closed]

I am running SQL Server 2014 SP 1 CU 5. The job did work in the past. The schedule is enabled. The account it is running under is an ADS account which has sysadmin rights and has delete rights to the ...
2
votes
1answer
24 views

msdb.dbo.sysjobs and last run date and time

I know that the last_run_date and last_run_time are stored as Int, but when coverted over to datetime (of which I have examples of), is the time GMT, or what? When converted it doesn't match the same ...
2
votes
1answer
82 views

TSQL Bulk Insert Syntax Error

I run the following code, received a syntax error. SQL Server 2012 Express (version 11) OS: Windows 7 home premium (x64 bit) The server complains that I have a syntax error near ...
1
vote
2answers
43 views

Dedicated SQL instance vs multiple database same server instance

Looking for best practice advice for a sprawling network. I inherited a bunch of SQL servers. The practice has been to just stand up a new VM instance any time a database was needed or add a new SQL ...
2
votes
0answers
43 views

Can SSMS Object Explorer Details configurations be exported?

A number of employees make use of SQL Server Management Studio (SSMS). I have a configuration file for all new users for Environment (etc) configurations. I want to deliver a uniform view for each ...
3
votes
1answer
38 views

Is EXECUTE AS OWNER in msdb a security risk?

I've been tasked with creating a system that allows non-privileged users to start and stop SQL Server Agent jobs. I'm creating stored procedures in the dbo schema in the msdb database using the WITH ...
1
vote
1answer
39 views

Avoiding a full re-initialization when making changes to transactional replication

When I use the GUI to make any changes to transactional replication on SQL server, I live in fear of the "the changes you have made require a reinitialization of all articles" dialog. I have had ...
0
votes
0answers
23 views

Any table type that persists across connections

Probably not possible,but I'm going to ask this anyway: I don't have OPENROWSET privileges on server B. I would like to import data while connected to server A (where I do have that privilege) and ...
3
votes
1answer
62 views

Amazing improvement of script execution speed when split - not understood

I have an ETL job that merges data into about 20 columns of a fact table, all integer non-null (default 0) columns. There are 8 merge statements to completely update all the columns and they involve ...
0
votes
1answer
41 views

Deny user to see any database through DB_NAME()

I've already prevented user to see any database (deny view any database to [login]) and it works. But how to prevent user to list any other database using DB_NAME()?
1
vote
0answers
48 views

Deadlock in SQL SERVER 2014

I am experiencing sporadic deadlock behaviour when my application tries to execute any DROP TABLE statement against my database. I tried capturing the deadlock graph and this is the output from ...
0
votes
0answers
24 views

Permissions required to add user to fixed server role

We want to take a group out of sysadmin but grant them a role so they can do the following add, change, remove database access on prod servers for users, groups and service accounts. create and ...
1
vote
1answer
34 views

SPID Change for a process?

On SQL Server 2012 can a process SPID change mid-operation? We have a very unique query that we've been monitoring (production, but controlled testing) and have seen it at different intervals with ...
5
votes
2answers
82 views

What sort of exec requests don't have a sql handle? (sys.dm_exec_requests)

I have crafted a query against SQL Server 2012 that looks like the following: SELECT r.session_id, r.sql_handle, t.text -- more details excluded for brevity FROM sys.dm_exec_requests r CROSS APPLY ...
0
votes
0answers
21 views

How to use a cross reference table for different features of a product in different versions?

I am creating a database for one of my classes. I am using SQL Server 2014. I am designing a database that monitors the source control of development of different products. This company has different ...
-3
votes
1answer
51 views

Where can I find the SQL Server to download? [closed]

I am new here, and I would like to ask: where can i download the latest SQL Server so I can start practising on my PC?
1
vote
2answers
44 views

Join two tables using pivot combining two columns in one table

I have two tables in this format: Job_Skill ID_Skill Min_Job Idea_Job Max_Job ===================================== 1 0 0 1 2 0 1 1 7 1 ...
6
votes
3answers
110 views

Query wont compile/run

I have a query that won't run on the production server but it runs on the test server. It seems like the query plan won't compile or its compiling a very bad query plan. I have updated all statistics ...
1
vote
0answers
27 views

Can I restrict an SQL account from system tables / functions?

I've got a piece of vendor software that comes with a MS-SQL database. The software has a user account configured to access the MS-SQL database. Is it possible to restrict that account from accessing ...
0
votes
0answers
18 views

Log shipping restore: Only members of the sysadmin fixed server role can perform this operation

On my secondary, I am seeing many messages like these in sysjobhistory from the LSCopy and LSRestore jobs for each database: Could not log history/error ...
1
vote
1answer
36 views

Use a scalar hashing function in a computed column - non-deterministic?

I have a scalar function select [dbo].[fn_get_hash_fields] ('blah','dbo') to which is passed a table and a schema and which returns an expression representing a concatenation of all column values ...
1
vote
1answer
29 views

Pivot three fields into one category

I have data in this format Skill Min Ideal Max ========================== C++ 0 1 1 I want to display it like this: Criteria C++ ================= Min ...
2
votes
1answer
61 views

Why is Include Actual Execution Plan not included in @@Rowcount when it produces a row count?

While updating a column in a table the last day I was shown a new technique by our Senior DBA to reduce reads and contention. The pseudo-code is WHILE [always true condition] BEGIN UPDATE ...
0
votes
0answers
32 views

SQL Server Agent job returns a failure status message after the job succeed.

We have a sql server agent job which runs every day on sql server 2008R2. The job has been running for years and had no issues before; and nothing has been changed recently. Two weeks ago, the job ...
0
votes
0answers
64 views

Trying to find a MIN() workaround for an indexed view

I'm trying to speed up a SQL Server query using indexed views and I have one slow element which I think is due to the use of GUIDs for the particular comparison column. The GUID can be mapped to an ID ...
3
votes
1answer
62 views

Inconsistent Execution Plan for Stored Procedure

We have a business-critical stored procedure that normally runs daily at 2am from a scheduled job (in an SSIS package) on the production DB server. The same procedure/package is called from a second ...
19
votes
2answers
1k views

When are computed columns computed?

When are the values for computed columns determined? When the value is retrieved? When the value is changed? Some other time? I'm guessing this is a novice question since I'm not finding anything ...
3
votes
0answers
21 views

Chance of skipping extended events when using an offset for the file target

I am exploring extended events and came across a question I can't solve using the Microsoft documentation : When reading events from the file target we can specify and initial offset so we can read ...
0
votes
1answer
19 views

sys.dm_exec_procedure_stats reset [duplicate]

I want to get stats from the sys.dm_exec_procedure_stats view. When I check the records from months ago, I see that after a point of time its stats reset daily, but there have been no server resets. ...
4
votes
2answers
369 views

Outer self join filters vs subqueries

I have a table storing information about tickets. There is one record when ticket is sold and another when ticket is used. There is a column called TransType which is set to either 'sold' or 'used' ...
-4
votes
0answers
30 views

what prerequisite are required to become a DBA?not overview but to the depth of course [duplicate]

what prerequisite are required to become a DBA?not overview but to the depth of course if any online link is there to learn or course to become DBA then let me know
6
votes
2answers
163 views

Does table size matter?

I have a table like this (with more columns though): CREATE TABLE [dbo].[MyTable]( [SnapKey] [int] NOT NULL, [SnapDt] [smalldatetime] NOT NULL, [Company] [varchar](4) NOT NULL, ...