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)

8
votes
2answers
120 views

Is the hierarchyid CLR open-source?

The built-in hierarchyid is a CLR that stores paths in an efficient binary form, and provides other useful functionality. Unfortunately, there is limit to how deep the represented paths can be, and ...
1
vote
1answer
59 views

how to uniformly select rows in sql

I am new to here and please let me know if I didn't make the question clearly. If I have a m rows in a table and I want to select n rows uniformly. In other words, the interval between first row and ...
6
votes
3answers
214 views

Execution Plan is NOT using INDEX and uses Table Scan

I know when it comes to using an index or a table scan, SQL Server uses statistics to see which one is better. I have a table with 20 million rows. I have an index on (SnapshotKey, Measure) and this ...
1
vote
0answers
33 views

2 SQL Clusters & 2 instances

Can anyone tell me why i wouldn't want to the architect Option 1 for SQL Server clustering? Option 1 is having 2 different clusters, and 2 different named instances on 2 VMs. One's Active is the ...
0
votes
2answers
40 views

Grant select on tables with a specific naming pattern

How to grant select on all tables starting with VVC_? grant select on VVC_* to user1
16
votes
7answers
395 views

Group daily schedule into [Start date; End date] intervals with the list of week days

I need to convert data between two systems. First system stores schedules as a plain list of dates. Each date that is included in the schedule is one row. There can be various gaps in the sequence ...
3
votes
1answer
73 views

TempDB uses a lot of space in buffer pool

I'm running a SQL Server 2014 with 2 cores and a max memory of 6GB. When I'm checking what's in the buffer pool, I see that TempDB uses 1GB of memory. That's the query I used: SELECT COUNT(*) AS ...
1
vote
2answers
33 views

Can we have dynamic SQL jobs in SQL Server Availability groups

We need to push all sql data changes to our local caching infrastructure in real time. We are using SQL Server 2012 Availability Groups. In the process of avoiding triggers for population SQL Service ...
6
votes
1answer
601 views

Why can a SQL Server table not have more than one IDENTITY column?

Why can a SQL Server table not have more than one identity column? CREATE TABLE t(id INT IDENTITY, id2 INT IDENTITY) Msg 2744, Level 16, State 2, Line 5 Multiple identity columns specified for ...
4
votes
1answer
122 views

how to ignore the SSMS (sql server management studio) sql server ansi settings?

The options in Management Studio On Management studio Tools->Options->Query Execution->SQL Server there are options that are set and these prevail over the same options that are set on database ...
14
votes
1answer
472 views

Where do this Constant Scan and Left Outer Join come from in a trivial SELECT query plan?

I have this table: CREATE TABLE [dbo].[Accounts] ( [AccountId] UNIQUEIDENTIFIER UNIQUE NOT NULL DEFAULT NEWID(), -- WHATEVER other columns ); GO CREATE UNIQUE CLUSTERED INDEX [AccountsIndex] ...
1
vote
1answer
40 views

Converting old SQL 2000 Non-Ansi code to SQL 2012 compatible

We have a legacy application that is only used for a read only reference. It is using SQL Server 2000. We want to migrate its database to SQL version 2012, however we can't upgrade the software and ...
-1
votes
1answer
55 views

UPDATE statement in a trigger occasionally updates some columns but not others [closed]

I have a table called NOTATION with the below table structure: ( NOTATION (primary key) TABLE_NAME , TABLE_KEY , NOTE_TIMESTAMP, SUBJECT , COMPANY , ...
0
votes
0answers
33 views

Log Shipping Backup Job Stuck at In Progress for several days

I have a SQL 2012 server with Log Shipping for 6 databases to a secondary server on the same network, however when checking SQL Agent for the backup job this is still at In Progress for all 6 ...
-1
votes
0answers
29 views

Using where clause to create a left join

TL:DR I have two tables Table1 and Table2. Table1 contains 1 row per request. Table2 can contain 0 to 20 rows per request. Current query simply gets data from Table1. I want to add Table2 to the ...
2
votes
1answer
52 views

Predicate re-write in where clause

How can I rewrite where col % 5 = 4 in SQL Server. The reason to rewrite this is because I am selecting some columns from the table based on this condition. Because of % used in where it is causing ...
1
vote
1answer
24 views

Scripting SQL Server Replication

I am trying to use SSIS to take a backup of Replication scripts. I am using Script task and using ReplicationServer class under Microsoft.SqlServer.Replication. The problem is, the package is ...
0
votes
2answers
81 views

Clustered Index Misunderstanding

I've read in couple of articles that clustered index is as the same as table, or if you read using clustered index, you have the whole record. Some say, clustered index stores the whole records in ...
0
votes
1answer
34 views

frequently dropping table in sql server

Kindly help me understand my below concern. In our current business requirement. We have to pull the complete data everytime. We have to truncate out table and load it with 20million of data. I want ...
4
votes
1answer
43 views

How can a database parameter be used on `sp_addextendedproperty`?

I have found the MSDN definition and code examples of 'sp_addextendedproperty'. In Example A on that page, I see an example of how to add an extended property to a database. USE AdventureWorks2012; ...
0
votes
1answer
40 views

ODAC OLE DB provider “OraOLEDB.Oracle” for linked server supplied inconsistent metadata for a column

I am using SQL Server 2014 linked server to connect to an Oracle 11gR2 (11.2.0.3) database, using the ODAC 12.1.0.2.4 Oracle OLE DB Provider. I have a stored procedure that lives in a SQL 2014 ...
0
votes
1answer
24 views

CMDEXEC The process could not be created for step… (reason: Access is denied). The step failed

I have created a job to test executing a CmdExec step. The job step is simply executing a batch file with dir as the command. The job is executing as the SQL Server service account. This account ...
1
vote
1answer
38 views

How to remove secondary file group

We have a SQL Server database with two filegroups; PRIMARY and SECONDARY, with a single file in each file group. All the clustered indexes are stored in the secondary filegroup. How can we remove ...
2
votes
0answers
45 views

Clustered index on a fact table

I'm trying to work out what field(s) to use for the clustered index of my fact tables (which all have a similar structure). I'll use FactSales as an example: CREATE TABLE dbo.FactSales ( ...
3
votes
1answer
40 views

Apply SQLServer Service Pack to a Single Node Cluster

I have to apply a SQL Server 2008 R2 Service Pack to a Single Node Cluster. The other node died and new hardware has been ordered. Is there anything weird to worry about? Normally we'd apply the ...
1
vote
3answers
44 views

How to replace column if not null in select statement?

I have a Contact (ID, FirstName, LastName, MiddleName). For example: | ID | FirstName | LastName | MiddleName | |====|===========|==========|============| | 1 | Mark |Jordan | E | ...
1
vote
0answers
21 views

Varchar PrimaryKey. Clustered or nonclustered? [duplicate]

I am working on a legacy database. The primary key is clustered varchar(128) and the table contains a high volume of data. Does it necessarily help performance if I change the clustered PK to ...
1
vote
1answer
73 views

Include scripts for Indexes on Alter Views

After a Developer altered an Indexed View to add a comment, the clustered index that was created on it was dropped with no warning. This caused a failure as there are a couple of procedures that have ...
0
votes
0answers
36 views

SQL Server 2012 service will not start after each server reboot - corrupt SQLBOOT.DLL

When I tried to start the service manually from a command prompt, I get a dialog stating: Your SQL Server installation is either corrupt or has been tampered with (Unable to load SQLBOOT.DLL (HRESULT ...
2
votes
1answer
46 views

Prevent SQL Job Agent from interpreting a quotation mark as apostrophe

I'm struggling with my SQL Job Agent interpreting a quotation mark " as an apostrophe '. I have a T-SQL query which works in SQL Server Management Studio but not when I insert the exact same ...
1
vote
1answer
43 views

Add New Cluster node

I have a Windows Server 2012 Failover Clustering Instance, hosting a SQL Server 2012 Enterprise Cluster, via NODE1 and NODE2. I need to add a new read-only Replica to this cluster: NODE3, which is a ...
1
vote
1answer
28 views

Database Mail stops working after browser service stopped

After stopping the browser service on a 2-node SQL Server failover cluster system, the Database Mail component stopped working. It fails and creates log entries as follows: ...
0
votes
3answers
48 views

Backup Error with Msg 3201, Level 16, State 1, Line 1 & Operating system error 3

When i am taking the backup in network share drive with mention below TSQL. Use DatabaseName Go Backup Database DatabaseName To Disk=N'H:\DatabaseBackup\DatabaseName.bak'; Go I am getting the ...
0
votes
1answer
40 views

Scalar UDF causing performance issues in SQL Server

I have a scalar UDF doing some string manipulations. When I use it in select clause it causes performance issues. I read that if we do not query tables or views in scalar functions it won't affect ...
2
votes
1answer
30 views

How do I modify a column type if the DB has many values

I'm currently trying to convert a column in SQL Server from nvarchar(255) to decimal(18,0). However, this is the error I get: 'member_details' table - Unable to modify table. Error converting ...
0
votes
0answers
29 views

Incorrect database backup file size in SQL Server 2008 R2

I am getting different sizes of the database backup file from SQL Server 2008 R2 even when backing up at very granular or frequent intervals. Scenario: I have taken database backup at 8:00am = ...
-1
votes
1answer
54 views

Patching SQL Server 2012

If I apply Cumulative Update 3 in SQL Server 2012 SP1, do I still have to do Cumulative update 1 and 2 before I can apply CU 3? And also, how would you know what CU's or hot fixes that has already ...
2
votes
2answers
27 views

Transactional replication subscriber vs AG secondary replica for reporting

I am trying to recommend my client a SQL server upgrade (from 2005-> 2014) which will allow the users to create record snapshot (via SSRS) from a read-only data source. Data latency should be kept to ...
3
votes
1answer
23 views

Store info in a column as JSON

I'm learning SQL Server 2016, I learned how to extract JSON from tables. Now I need to store JSON in a column. My JSON was: {"endereco":"R. Nome da Rua, 000", "cep":"00000-000"} I`m using nvarchar ...
0
votes
2answers
35 views

How do i find out the most active database?

How do i find out the most active database? I mean to say I have 10 DBs and some transactions keep on happening on these DBs. I want to know which is less used or which DB has less no of ...
3
votes
2answers
138 views

Best fill factor for GUID clustering key

We have a database that uses GUIDs for most of their columns in a data (non sequential). Does anyone have any best recommendations for fill factors on a GUID database in an hgih insert/update ...
0
votes
1answer
13 views

Enabling IPAII protocol disable remote conections. Why?

I have some servers with IPAII protocol enabled with a certain port: I'm using 1433 because a long story. but its working. We can use the default port 1433 AND IPAII ( for PHP developers ) with ...
7
votes
1answer
107 views

Should I disable HyperThreading

BACKGROUND I've recently been looking into some fairly high CXPacket wait times recently which has had me using SQL Sentry to monitor processor activity pretty closely. One thing that I've noticed as ...
1
vote
2answers
41 views

SQL Server engine in one place with database files on NAS

My office uses accountant programs which run on SQL Server 2008 R2. The SQL Server engine must be installed on one of the laptops (called "server") and the other laptops (called "clients") connect to ...
3
votes
1answer
30 views

Extract Multidimensional JSON

I have some tables: teste // id, descricao teste2 // id, descricao relacao // id, idTeste, idTeste2 With this structure, I got all products owned by a client. Now I'm trying to use FOR JSON PATH to ...
1
vote
2answers
81 views

How can I improve performance on a 3 table query?

I'm attempting to analyze a resource drawdown (the percentage of time individual units are being utilized during a reporting period, e.g. 2-weeks or 1-year). I need the aggregation down to the ...
3
votes
1answer
50 views

SQL Server Clustering - Active/Active or Active/Passive?

What is the logic of the Active/Active cluster vs Active/Passive cluster? I have searched a lot and read lots of documents but have not found the answer. In active active cluster can I have 1 ...
3
votes
1answer
46 views

How does SSMS get a list of files in a backup?

When restoring a database that has multiple files, SSMS gives you the option to restore as other paths and file names. How does it retrieve the list of files from the backup? Can I do that in a SQL ...
0
votes
0answers
32 views

SQL Server Trigger: Move deleted rows from 4 different tables to an archive table

I have a garage database with 20 tables. 4 of these tables - tCar, tCustomer, tAddress and tTelephone hold data about when we service a car. After a few months I want to be able to delete the data ...
1
vote
1answer
19 views

Managing Security for a Log Shipped db across two (unconnected) domains

SQL Server 2008 (soon to be 2012). We have a vendor that is providing us with log shipped backups of our production database. We use this log shipped database for BI staging, reporting, etc. I've ...