Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql-server-2012]

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

1
vote
1answer
53 views

Conversion of Row into Column

I'm in very weird situation and i have researched a lot but not able to find anything similar to this scenarios. Input looks something link this. Where Each patient has Primary Dx code, Admit Dx ...
0
votes
2answers
86 views

DBCC CHECKDB - SQL Log Says Completed, SQL Server Agent Says Failed

I run a nightly Integrity Check (set up via Maintenance Plans) on all of my databases. For the last two nights, the final CHECKDBCC has failed... at least according to the SQL Server Agent Job. ...
1
vote
1answer
24 views

How to setup encryption on a column that joins two tables in two different databases

What is the best method to encrypt a column that exists in two tables (BUID) in two different database on a 2012 server, at the end should be able to join on the encrypted columns between two tables ...
0
votes
1answer
642 views

SQL Server Average Lock Wait time Historical data

Monitoring software has indicated average lock wait times rising to 500ms during the night. Is there any way of confirming which locks these were as we currently do not log any performance data to a ...
7
votes
3answers
7k views

How to import blanks as nulls instead of zeros while importing txt using wizard

I'm using the Import Wizard to load a text file and need blanks in integer fields to be nulls, but only zeros are inserted. How to import it properly?
1
vote
1answer
53 views

Convert SQL Server results to a text file that PowerShell can access and use

The query below is used to create a text file with a list of server names. The problem I have is that the text file gets created like Server, Server, Server etc. but I need it as follows Server ...
0
votes
1answer
1k views

Persistent Data Collector Collection_Set_3_Upload Job Failure with AlwaysOn Groups Enabled

I have a two node SQL 2012 AlwaysOn HADR cluster (v11.0.3412) with 3 availability groups configured. The AG groups are set to synchronous mode and the secondary is not readable (we do not want the ...
15
votes
4answers
937 views

What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?

Currently, we have an existing database and application that is fully functional. I do not have the ability to change the architecture at this point. Today, each table in the database has an "...
16
votes
2answers
1k views

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

I have written a stored procedure which makes use of a temporary table. I know that in SQL Server, temporary tables are session-scoped. However, I have not been able to find definitive information on ...
0
votes
0answers
25 views

pivot vs multiple columns

I have a table that I've been tasked to look at for optimization (both for entering data through stored procedure, and for views based off the table). The table has (currently) 115 columns, 2 make up ...
1
vote
1answer
52 views

I want to change to Dynamic SQL Query instead of CASE statement [on hold]

I have two tables as below and description is given in below Employee table id EmployeeID departmentid department1 department2 department3 1 300 100 IT Finance ...
0
votes
1answer
44 views

Drop the user from Read only Secondary database Always ON server

How to drop a user from the secondary database in an AG when it is in read only mode and synchronizing in SQL Server 2012? The login and user have been deleted from the primary database, and we are ...
1
vote
1answer
19 views

Is there any way to find information of index fragmentation, Statistics information with the help of system tables in SQL Server

I am working on a report which will give information for different segments like blocking process, slow running queries, disk space etc. I also want to add one more segment where I can get information ...
47
votes
2answers
67k views

How to join a table with a table valued function?

I have a user defined function: create function ut_FooFunc(@fooID bigint, @anotherParam tinyint) returns @tbl Table (Field1 int, Field2 varchar(100)) as begin -- blah blah end Now I want to join ...
3
votes
1answer
687 views

Shirking of Log file on Primary Server of Transaction Log shipping

I have a database with size 200 GB Total(mdf+ldf) and Log file(ldf) with 50 GB and 99% unallocated space in ldf file i.e. not being used at all. We had setup log backups for every 5 minutes, so there ...
2
votes
1answer
51 views

CTE Query to CONCAT text (over 10,000 rows)

I am trying to construct a CTE query to loop through rows of data and concatenate text into one line for each SampleUserNumber. Below is what I am working with: CREATE TABLE #SampleTable ( ...
-1
votes
1answer
25 views

SQL Admission Count using row_number

I'm new in SQL Server learner and I'm stuck in simple problem to count the admission using SQL Server in healthcare data set. Sample table: create table admissions ( HIC char(1), DateFrom date, ...
0
votes
2answers
52 views

Triggers vs. Jobs in SQL Server

I’m designing a database with a table that automatically gets loaded with a new record every 15 seconds (each record will have a 'timestamp' field and around 50 ‘float’ fields). Each record in this ...
2
votes
2answers
38 views

Selecting the same column from Different rows Based on Different Criteria

My table creates a row for each customer name for the unique customer number. CREATE TABLE #src(Number int, name varchar(32), seq bit); INSERT #src(Number,name,seq) VALUES (12345,'Mickey Mouse',0), (...
4
votes
1answer
72 views

Seeking Help Optimizing Self-Joins

This query takes ~5x longer than it should due to the WHERE IN() statement at the end. I am a junior DBA in over my head trying to figure out a way to optimize it. Is there a way to check IN() the ...
0
votes
1answer
35 views

Need Help in extended events SQL Server

I have created an extended event as below. I want to know how to query the historical data using T-SQL to see the issues at particular timestamps. The trace is running as of now CREATE EVENT SESSION [...
1
vote
1answer
17 views

SQL Services Wont Start After Removing TLS [duplicate]

I need to remove TLS 1.0 from one of my SQL servers. When I do so and then reboot the server the SQL services dont start automatically. When I attempt to start them I get an error that it cant be done....
0
votes
0answers
27 views

Create SQL Server Agent job for stored procedure with input parameter

Could you suggest please how to create SQL Server Agent job for a stored procedure that have 1 input parameter? The procedure is correctly created and i executed it using this code : EXECUTE dbo....
7
votes
3answers
10k views

The Service Broker endpoint is in disabled or stopped state - AoAG - SQL Server 2012 - 15 minute interval

I receive this error message in SQL Server error log every 15 minutes. I have setup AOAG on this server. The database option "Service Broker - Broker Enabled" is turned on for the Blackberry related ...
0
votes
1answer
93 views

Keeping my database updated every 30 minutes using Log files

I have a situation where I get a full nightly backup and trans log backup every 30minutes starts at 7:00 am ends at 2:00 am. I need to restore them every 30 minutes into a database and replicate this ...
-1
votes
0answers
19 views

Compare 500 files and load only distinct record

I have 400 to 600 different files and with same data type. But in these files, we have so many duplicates record in all the files. In my folder, there are A.txt, b,txt, c.txt files are there. It ...
3
votes
1answer
154 views

Optimize query without rewriting it - vendor app

Here is a query that uses a lot of CPU on my SQL Server (8 cores): DELETE TOP(1) rd FROM (SELECT TOP 99.9999 PERCENT * FROM APM_IisBb_Request_Details ORDER BY RequestDate ASC) rd JOIN ...
1
vote
1answer
2k views

How to create an INSERT/UPDATE/DELETE trigger

My knowledge with triggers is very poor. I want to create an INSERT/UPDATE/DELETE trigger on a tableA with column names (A1,A2,A3,A4,A5,A6). After the triggers fires, I want to put that data in ...
0
votes
1answer
33 views

Security admin access [closed]

I have plans to leverage security access request to L2 team to manage their create and modify logins permission in SQL server 2012. So that they can manage the Grant and revoke permissions for ...
0
votes
1answer
437 views

Drop a replicated subscription table that has been orphaned after restore migration

We restored a database on a new server for a migration. When attempting to set a subscription to a transnational publication, we get the error: Can't drop the table because it is set for ...
0
votes
2answers
93 views

Granting a SQL Server database only user execute on xp_instance_regread fails

So I'm not finding an answer to my specific issue. SQL Server 2012 database SSMS 17 admin tool Log on as a database (not domain) user foo. Receive sys.xp_instance_regread no permission errors. In ...
1
vote
2answers
67 views

SQL Server - Extremely low avg_page_space_used_in_percent for heap table

While analyzing a SQL Server 2012 database bloat issue, I found that fragmentation might be a major contributor to how much space is being taken up by certain tables, so after some Googling, I'm ...
7
votes
1answer
2k views

Query External LDAP Server from SQL Server

I have done extensive research on querying LDAP Server but so far has not been able to work around. Therefore, asking experts help Background: I have a client whose LDAP Server is OnPremise (though ...
3
votes
3answers
4k views

How do I detect execute permission granted to a role (when no ON clause was used)

I just spent hours trying to figure out how an app had privilege to execute stored procedures. TIL from StackExchange: Turns out the ON clause is optional for GRANT, allowing a role to be granted ...
1
vote
2answers
618 views

New Server Query AD is giving permission error

We replaced a physical server with virtual, I copied all the logins, and linked servers from the old server and restored all the databases from the old server to the new. Everything works fine except ...
0
votes
1answer
36 views

Setup Multiple SQL Server Tree Structure similar as RDC based on Enviornments

I want to setup multiple SQL Servers like a tree structure similar to Remote Desktop connection Manager, where we can setup multiple servers based on environments we support like Test and Prod.
0
votes
1answer
93 views

Performance Degradation Troubleshooting [closed]

I get periodic slows where the CPU goes high for a period of time which I can occasionally simulate via a query. It almost seems like it happens when the data falls out of cache which seems to happen ...
0
votes
1answer
35 views

How to get MSSQL Type definition from system tables?

If I have a user table type (like CREATE TYPE ...), how do I get to it's definition in the system tables? I know I can see it through SSMS through GUI, but I would like to have a query to retrieve ...
0
votes
1answer
15 views

Query error: there is no matching unique or primary key constraint in the referenced table

I am getting an error of *Cause: A REFERENCES clause in a CREATE/ALTER TABLE statement gives a column-list for which there is no matching unique or primary key constraint in ...
19
votes
1answer
18k views

When to use sort_in_tempdb when rebuilding indexes?

We are debating whether to use the SORT_IN_TEMPDB option for our DW tables. My understanding is that there are more writes when using this option, although they are more sequential. We have a SAN (...
1
vote
1answer
370 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 ...
0
votes
1answer
15 views

SQL 2012 Replication Between Subscribers Across VPN

I have been assigned with setting up replication for an instance(remote instance) at a geo location that we access across a VPN. The remote instance will need to send the transactions to a local ...
0
votes
1answer
44 views

SQL - Update certain database records with a loop

I have a certain IDs in a table that I would like to change a column value from false to true. How can I do a loop that goes through the specific IDs given and changes a column value from false to ...
3
votes
2answers
113 views

How to remotely connect SQL Server 2016. Since we have 2012 and 2016 in same server

Issue I am not able to connect to a SQL Server 2016 instance on a remote system/server. My Existing Environment Windows Server 2012 SQL Server 2012 and 2016 installed on same server I tried to ...
0
votes
0answers
247 views

SQL Transactional Replication - some tables frozen, but others working fine

Background We are "republishing" 20 SQL Server 2012 source databases, using SQL 2016 as the republisher and subscribers, with SQL 2017 acting as the single distributor for both "hops" (Hop 1 being ...
1
vote
1answer
91 views

Querying mirrored database

I need to create a snapshot of one of our mirror databases. I have gone through a couple of links and it looks like querying can be achieved here by creating a snapshot at a mirror server. However, ...
-2
votes
0answers
18 views

SQL Server 2012 on Windows 2016 installation issues

I have tried to install a fresh install of SQL Server 2012 on a Windows Server 2016 several times now. I had to add 3.5 framework as expected, and I got errors that prevented the database engine from ...
2
votes
1answer
93 views

Direct values on predicate produce not-so-good plan

I'm using StackOverflow dump to run some tests. In particular, I'm querying this table: I have created this index: I'm running the following query (just forcing an index to test alternatives) I ...
0
votes
0answers
18 views

What are SSIS ,SSRS and DB engine SQL server 2008R2 to 2012 IN PLACE UPGRADE steps and cautions? [duplicate]

I am trying to find, SSIS ,SSRS and DB engine SQL server 2008R2 to 2012R2 IN PLACE UPGRADE steps and cautions ? Thanks, DL
1
vote
1answer
86 views

Transaction log rollback broke Log Shipping chain?

Is it correct that performing a transaction log restore to a previous point in time will break the log shipping chain? If this is correct, is there a way to recover from this situation without having ...