SQL Server 2012 (major build version 11.00.xxxx). Please also tag sql-server.

learn more… | top users | synonyms (3)

4
votes
2answers
65 views

Statistics for AlwaysOn Availability DBs

Can you please help me understand why there is a need for SQL Server to maintain statistics in tempdb for DBs that are part of an Always On Availability Group? Isn't "everything" that happens in the ...
3
votes
1answer
71 views

Correlated subquery to find total larger than state average

I have tables Vendors (VendorName, VendorState,....) and Invoices (InvoiceID, InvoiceTotal,...). I want to get the Invoices (as InvoiceId) that are larger than the Avg state InvoiceTotal. I know I ...
3
votes
2answers
83 views

Max date record for items for given set of dates

I am looking for some help to create an efficient SQL query (SQL Server 2012) that will identify the latest records (date) for all the items in the table (table 2 below) on each of a list of given ...
-3
votes
1answer
21 views

SQL Server 12 Instance / server name change

I created a sql server instance and the name show up differently in test and prod. How can i change the prod name to not have the names repeating ? Prod : select @@servername EHCPSQL12\EHCPSQL12 ...
15
votes
1answer
214 views

Multi-statement TVF vs Inline TVF Performance

Comparing some of the answers on the Palindrome question(10k+ users only, since I've deleted the answer), I'm getting confusing results. I proposed a multi-statement, schema-bound TVF which I thought ...
6
votes
0answers
109 views

SQL Server Sharding strategy optimization

I have implemented a sharding solution for our SQL Server databases as per the MSDN documentation here: https://msdn.microsoft.com/en-gb/library/dn589797.aspx This has been running for around 6 ...
0
votes
1answer
26 views

DR site SQL Server DB server not need Quorum Disk?

We have two SQL Server DB Servers and Shared disk in production site and 1 DB in DR Site. Production site has Quorum Disk on Shared Storage. Production site DB servers can access this share storage, ...
4
votes
1answer
353 views

Difference between clustered index seek and non clustered index seek

What is the difference between Clustered Index (CI) seek and Non Clustered Index (NCI) seek? Does one perform better than the other? The reason I am asking this is because I have a table with 50 ...
0
votes
1answer
18 views

Implementing a Scalable shared reporting platform

Im starting to implement a Shared Platform that will host multiple BI/Reporting applications. The platform is required to be as scalable as possible and im also thinking how to achieve Load Balancing ...
2
votes
2answers
118 views

Stopping SQL Server Log Reader Agent In 2012

We implement Transactional Replication with 2 publishing servers, 4 publications and 1 subscribing server. I need to shut down our distribution server for several hours. When restarted, will the Log ...
1
vote
0answers
38 views

SQL Server cannot find local SQL Server accounts

All local SQL Server accounts are getting a windows application event log The description for Event ID 18456 from source MSSQLSERVER cannot be found. Either the component that raises this event ...
2
votes
0answers
53 views

Does Trace Flag 8295 applies to SQL Server 2012?

I've been searching about the undocumented Trace Flag 8295. It's been introduced with KB 2476322 in SQL Server 2008 and "'Creates a secondary index on the identifying columns on the change tracking ...
0
votes
1answer
69 views

comparing left join and outer apply doing the same thing

I have an update trigger on a table that that insert rows in another database/table the query look like insert into otherdb.table select manyfield from inserted left join (select id, ...
0
votes
0answers
37 views

Can we track data changes on all SQL Server tables based on primary-foreign key relationships?

Let's say I have a Customers table with primary key as Customer_ID and 10 more SQL Server tables with Customer_ID as foreign key. Without keeping triggers on all 11 tables, is there a way to track ...
1
vote
3answers
76 views

SQL Server Select in XML field

I need a help with the situation below: In my table SQLServer 2012 have a field with xml values, I would like to make a select of the data in that field and show the result in the form columns. &...
0
votes
0answers
14 views

SSIS package for Table copy dynamically [duplicate]

I wants to copy a table structure along with data dynamically using SSIS 2012 from a DB server to another DB server. The server and database exist physically. The user would provide 5 parameters. ...
19
votes
9answers
4k views

Test if a string is a palindrome using T-SQL

I am a beginner in T-SQL. I want to decide whether an input string is a palindrome, with output = 0 if it is not and output = 1 if it is. I am still figuring out the syntax. I am not even getting an ...
2
votes
1answer
62 views

What happens when two separate processes perform a full backup against the same database?

I have an instance of SQL Server 2012 RTM running. I have two separate applications that want to do a backup of a database lets call them "AppFull" and "AppFullCopyOnly". AppFull does a full ...
4
votes
1answer
116 views

Slow Delete's of LOB data in SQL Server

I have a tables for logging, and a stored procedure to purge old data that has very slow DELETE performance, beyond what makes sense to me. I am looking for how to modify the tables or DELETE ...
0
votes
2answers
37 views

Error When Trying to Run Subquery

I am having issues getting my subquery to run properly. Everything runs quickly and correctly until I add the subquery. I get the error: "Msg 4145, Level 15, State 1, Line 66 An expression of non-...
1
vote
1answer
44 views

Capitalize only the first letter of a name

I have a table Vendors that contains a column VendorContactFname, which is written in lowercase. I want to capitalize only its first letter. I am thinking of concatenating an Upper on the first ...
2
votes
1answer
40 views

Relating 2 tables with possible wildcards?

I am having trouble getting the desired results when trying to relate the following tables. NULL in the following table essentially means that if it is not an exact match with another row then choose ...
2
votes
3answers
101 views

To find SQL Server is actually used or not?

I have an SQL Server 2012 and a 2008R2 running in my environment. I need to decommission the server if the server is not actually being used. I did go through this and this where connection count is ...
0
votes
1answer
61 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 ...
0
votes
1answer
71 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 ...
1
vote
0answers
33 views

How can I import data from a NetCDF file into SQL Server?

I'm being asked to investigate the feasibility of importing data from a NetCDF file into SQL server. The file could be upwards of 300-400Mb and provided 4 times a day. However I'm only interested in ...
5
votes
2answers
96 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
38 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 message.(Microsoft.SqlServer.Management....
2
votes
1answer
73 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 [......
4
votes
2answers
391 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' ...
6
votes
2answers
181 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, [...
0
votes
0answers
10 views

Workload Capture

Hopefully this is a straight forward question. But if I want to capture a workload then all I need to capture are: RPC:Completed SQL:BatchCompleted I don't need to capture SP:StmtCompleted do I, ...
2
votes
1answer
129 views

What is the best way to import this non-standard text file into SQL Server?

I have a text file that is generated daily. It is a fixed width format with one frustrating exception. The third column (NAME) has a variable width. The column is always exactly as long as the longest ...
0
votes
1answer
58 views

sql server 2012 Express bulk-insert fialed due to message Operating system error code 5(Access is denied.)

I used my personal laptop computer (Samsung RV520) OS: Windows 7 home premium (x64 bit) SQL Server 2012 Express version 11 I encountered an error when execut the code below. error message: Msg ...
0
votes
1answer
53 views

Duplicates when checking for two different column values based on a key that is not unique in table

I want to check to see if two orders were placed for one person within an hour of one another. Example data PERSONID | proc_code | TIME 123 | 1 | 4/25/2016 00:01:00 123 | 2 | 4/25/2016 00:01:00 123 |...
0
votes
0answers
34 views

Unable to Remove Filestream Filegroup and Associated Database File

I had 5 FileTables which I have since converted to regular tables with varbinary(max) columns instead, migrated all the data from the filetables to the new tables and dropped the filetables completely....
0
votes
1answer
54 views

Sql service account password change for environment on Availability groups 2012

My current environment is on Availability groups sql 2012 with 1 Synchronous and 1 Asynchronous replica. Soon we need to change the sql service account passwords. Can any one suggest to me do I need ...
3
votes
1answer
52 views

After processing complete, SSAS DB slowly consumes all available space on disk, w. high memory use also

This problem is with an SSAS 2012 SP3 (11.0.6020.0) multi-dimensional server, hosting a single cube database, containing 1 cube and 16 dimensions. Aggregations have been designed using SQL Management ...
2
votes
1answer
414 views

Having 2 identities in a table

I need to have some how 2 identity columns in one table. One that is normal identity and another one that will reset yearly. I have done the reset part with the help of DBCC CHECKIDENT ('TestTable', ...
1
vote
1answer
24 views

Transactional replication using articles filters and delete operations

I have a problem with my transactional replication when I use articles, filters, and delete operations. When I insert the new data into the publisher all the data that meets the specified filter is ...
0
votes
2answers
67 views

How can I return top 10 rows from each state [duplicate]

How can I return the top 10 rows for each category? Say I have a table named xyz. It has a column called state, in the political unit sense of the word. I want the top 10 rows from each state. Do I ...
0
votes
1answer
74 views

Copying data from two tables into one using INSERT in SQL 2012

I've been trying to copy data from two tables into one using the INSERT statement. The tables are from the same database and have the same numeric types and I only need to copy one column from each ...
7
votes
3answers
265 views

Execution Plan is NOT using INDEX, It 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
2answers
53 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 ...
0
votes
0answers
50 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 ...
2
votes
1answer
57 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
85 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
94 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 ...
1
vote
1answer
53 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 ...
0
votes
2answers
91 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 ...