Questions tagged [sql-server-2012]

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

Filter by
Sorted by
Tagged with
-4
votes
1answer
32 views

Case statement syntax error [closed]

I am trying the code below but the SQL throws an error case when (b.ModuleType in (20) and rtrim(substring(a.PrdAcctId,1,8))='RD') then (a.Balance1+(a.Balance2-(a.Balance3+a.Balance4)) when (b....
0
votes
0answers
42 views

SQL server IN Clause usage with Pivot table

I have a problem with pivoting a table on MSSQL. The main problem is, when I want to fetch row values in an inner query (with IN clause) I get syntax errors but when I type the values statically, it ...
0
votes
1answer
41 views

SQL server: Any user can access database instance without any grants [closed]

User created from Active directory can access all instances of databases in SQL Server without any grants. Was shocked to see this behaviour on our environment. Example. We have a database named MyDB ...
0
votes
0answers
57 views

transaction log grows despite recovery=simple. SHRINKFILE does not release space

I have this script that restores a DB, sets recovery=simple, trims some tables & shrinks files: RESTORE DATABASE [ABC] FROM DISK (....) ALTER DATABASE [ABC] SET RECOVERY simple go exec [ABC]..trim ...
1
vote
1answer
46 views

Connect to local instance after leaving domain account [duplicate]

Yesterday, I switched from a domain user account to a local user account in Windows. Before the change, I could connect to my local database instance, but after leaving the domain, I cannot connect ...
0
votes
2answers
30 views

Track deleted user in SQL Server?

Is it possible to track which user was deleted from SQL Server and when was it deleted?
3
votes
2answers
49 views

Question Regarding ISDATE Function and DATENAME Functions

We have had an issue this morning with a report failing due to the following error: "Conversion failed when converting date and/or time from character string" The issue is that in the ...
-1
votes
0answers
43 views

Select from a table when the name of the table is specified in a select statement? [duplicate]

I have the following query where dbo.TEMPLATE.TITLE returns the name of a table that contains additional data that I want to retrieve. Can I do a subquery in my statement that selects from the ...
5
votes
1answer
113 views

SQL Server 2012 equivalent of AT TIME ZONE capability

Is there a way in SQL Server 2012 to get what the server time zone would be on a particular date/time? In SQL Server 2016, you have AT TIME ZONE, but that's not available in 2012. I have a ...
0
votes
2answers
61 views

Solution for syncing a database between two server and secondary can be used for all DML operation

I need a solution to synchronize a database (SQL Server 2016 Enterprise) between two servers, and I would be able to connect my secondary application to the secondary database which is getting ...
1
vote
0answers
16 views

How to Enable TLS 1.2 on MS SQL Server 2012 SP1? [duplicate]

im having trouble connecting to MS SQL Server 2012 SP1 with regards to TLS Handshake. as stated by microsoft, SP1 only supports TLSv1 to TLSv1.1, if i'm not mistaken. I have been developing a spring/...
0
votes
1answer
42 views

SQL Server 2012 memory Issue

We are currently running SQL servers 2012 on machine having 64 GB memory. We have a SQL server that is currently using up all the memory allocated (45GB)to it, after consuming all the allocated memory ...
0
votes
1answer
72 views

Return unique records based on shared column in 3 tables

This is the database schema that I'm working with and I've included some sample data as an example of what is currently in the database. CREATE TABLE Visits ([ADATE] date, [AKEYTIME] varchar(10), [...
-1
votes
1answer
80 views

How to execute join statement dynamically without using static group id? [closed]

I work on SQL server 2014 I need to run this statement below dynamically without using group id static because I don't know maximum group id using may be 10,15,20 so How to run query below dynamically ...
0
votes
1answer
17 views

EXECUTE AS LOGIN failed with local windows group login

I'm troubleshooting a permission issue that I tried to perform the query below EXECUTE AS LOGIN = 'ComputerName\Windows Group Name'; SELECT * FROM fn_my_permissions(NULL, 'SERVER'); SELECT * FROM ...
0
votes
3answers
79 views

Sum date between two date and group by month

I have a table as below: Name Start Date End Date Joe 20/04/2021 20/05/2021 John 01/05/2021 28/05/2021 I am using a SQL table-valued function to return a table that has 2 columns: Month and ...
0
votes
2answers
42 views

Get the Record where only Two Records exists in SQL

I want to get the parentID where user1 and user2 are using and only the two of them are using. for example, ParentTbl | ID | Remarks | |------|--------------------------------|...
3
votes
1answer
46 views

Database Unallocated Space - Correct way to measure

I am confused over the web regrading few scripts on calculating the database size and free space within same. Most of the scripts over the web uses sys.databases_files dmv to calculate free space like ...
0
votes
1answer
31 views

Run SQL Job monthly at day 16. If it's a weekend, run it in the next business day ( dont care if is a holiday)

I need to run a job every day 16. But if it is "saturday" or "sunday" it must run in the next business day. I don't care if it is holidays or not. I just need to run it. I could do ...
1
vote
0answers
35 views

Can I use SQL Server Developer edition (free license) for Non-Production environmen that is used for training [closed]

Client uses SQL Server 2012 Dev environment for Training, is this regarded as a Prod or Non-Prod activity? Please point me in the direction of a Microsoft documentation for this scenario. Thank you.
0
votes
2answers
131 views

Get data between date range

I have a range of tabular data with two columns for dates Start Date and End Date and I want to pick up everything either Starts/Ends on coming Monday 03/05/21 or Starts/Ends on Sunday 09/05/21 and ...
0
votes
1answer
40 views

need the rows with a unique value on certain columns but date column doesn't help?

I have a table with multiple records by each employee. I need to find all the records by employee where any of the columns values changes. For example, I have the following data for George: CREATE ...
1
vote
1answer
39 views

Significant performance differences executing alter and grant statements between users with same permissions

I am experiencing significant performances differences between users with the same permissions when executing alter and grant statements. I have an automated build system that runs a series of SQL ...
0
votes
1answer
30 views

SELECT only the rows with a unique value on certain columns [closed]

I have a table with multiple records by each employee, i need to find all the records by employee where any of the columns values changes. for example i have the following data for George: HOME ...
0
votes
1answer
29 views

How to find if the application uses the database snapshots in Management Studio [duplicate]

I'm taking over dba responsibilities for the migration of an environment that the application owners are unable to give enough information on. I need to comment on possibility of optimizing licensing ...
1
vote
1answer
34 views

Thousands of After Insert and Update Triggers Causing Performance Issues

We have a After Insert and Update trigger on one of our tables. The trigger basically makes a json payload and enqueues it in a RabbitMQ system. Today a large insert script was run on the table (over ...
0
votes
1answer
38 views

How to get SQL Server Developer edition for installation in non-production for the organisation

Kindly shed some light on this for me please. Through my free membership of Visual Studio Dev Essentials, I have a free copy of SQL Server Developer edition installed on my personal machine. How can ...
0
votes
1answer
44 views

I need to create a process where anything older than six months we would write to an archive table and delete the records from the inventory table

I need to create a process where anything older than six months we would write to an archive table and delete the records from the inventory table. Our inv table is huge btw lets use (x) as the number....
0
votes
2answers
63 views

Total logical reads per database on SQL Server

Is there a way to get the total running logical reads\writes per database from last restart? Trying to monitor what dbs are most used and if that changes over time.
0
votes
1answer
52 views

Index Reorganize fails

I am using the default SQL Server Maintenance task to reorganize index only which was running until I got the below error. Executing the query "ALTER INDEX [PK_abc] ON " failed with the ...
1
vote
1answer
44 views

How Restore backup as overwrite on a database in use in SQL Server? [closed]

I Want to restore a backup with overwriting on a database in use for this problem I want to create a query base on these steps : 1- Remove All Connections [MyDB] 2- Create a backup from [MyDB] 3- ...
0
votes
1answer
30 views

an element with the same SQL SERVER key has already been added

Good morning community, I am having problems when I run this query from SQL 2018 and Visual basic 2010 shows me the following error "an element with the same key has already been added" ...
0
votes
0answers
22 views

How To Grant A Specific Login Under Acitve Directory Group To View Server State In SQL Server [duplicate]

I want to grant only a login who is under an active directory user group to view server state in sql server. How can i do it?
0
votes
0answers
72 views

SQL Server 2012 stop working after specific time

SQL Server 2012 stops working after every 6 to 7 hours, SQL Server Management Studio not connected, almost every service related to SQL Server stops, after system restart every service is working fine,...
2
votes
1answer
152 views

“dateformat” independent form of datetime string in query for SQL Server?

I am unfamiliar with SQL Server, and would like to do some ad-hoc searches in a dockerized legacy SQL Server database using SQL Server Management Studio where one of the fields is a datetime and I ...
1
vote
1answer
44 views

Avg write latency spikes for disk more than usual. Need help finding the culprit

We recently had increased in disk write latency reported. Though from our monitoring team it was not confirmed from which drive but doing some dmv query I see tempdb around avg 32 ms wait on write. ...
2
votes
2answers
96 views

How to hint Remote Scan operator to estimate more than 10000 rows?

I need to read data from a linked server and insert into a local table. I need to remove duplicates in data and I need to do it on a local server, because remote server is overloaded. So, I added ...
0
votes
1answer
22 views

Logshipping is failing intermitently

Client has setup logshipping one of the database. Out of 3 steps in logshipping - backup and copy works without any issues, but restore fails intermittently giving 'out of sync' error. When I pulled ...
-1
votes
1answer
62 views

Can you index on a field that isn't in your table?

I've got two tables, appointment and patient. In this case, I only care about the patient table insofar as it joins to the appointment table. If the patient doesn't have an appointment in a given time ...
1
vote
1answer
35 views

SQL encrypted connection home experiment

I have a home SQLserver 2012 that I managed to enable "force encryption" on, using a self-signed certificate and configuration manager. Now I find two things I can't explain: Once "...
2
votes
1answer
75 views

Limiting total number of records in a table with a nightly job

We have a table that stores audit records (Log in, log out that kind of thing), we already have a nightly job that archives any data that is older than 3 months. However every week or two we get ...
1
vote
3answers
65 views

Shrinking data file to save disk space before migration

I know this is most discussed answered on various forums: I completely understand answer is no in most of the time or cases. However want to know if it can be good approach under any scenario: Lets ...
5
votes
3answers
941 views

Size Requirement of SQL Database

I have been asked this question in an interview that how much would be the DB size for a standalone SQL server if 650MB of data is processed every month. I couldn't give any answer to this question in ...
0
votes
1answer
33 views

Create a trigger to fill a field according to acondition in sql

I want to create a trigger to fill a field according to acondition as below description For example: I have a table for all insps that have attachments named: “inspectionAttachments” and I have ...
0
votes
1answer
44 views

hide instance not working

We do not appear (yes/No) for hide instance in SSCM for all SQL Server 2012 servers. We are unable to see (yes/No) option for hide instance . Kindly assist me here . Thanks a lot !
0
votes
0answers
56 views

Get actual Job Name of the running SSIS package from Program Name column of the results while running sp_whoisactive or sp_who2

When I run sp_whoisactive or sp_who2 and if there is a SSIS Package running it would always display in the Program Name as the name of the running SSIS Package like SSIS-Package-{063BC46B-1F74-4207-...
1
vote
3answers
212 views

Get actual Job Name from Program Name column of the results while running sp_whoisactive or sp_who2

I am running sp_whoisactive on my Prod and offload the data for analysis. When I run sp_whoisactive or sp_who2 and if there is any SQL Agent Jobs running it would always display the Program Name like ...
2
votes
2answers
463 views

is it safe to compress backups for databases with TDE enabled?

I've been reading about this for a long time, and it seems it's not safe to compress a backup when the database has TDE enabled. is anyone experiencing errors during restore with compressed backups ...
0
votes
1answer
840 views

Cannot fetch a row from OLE DB provider “SQLNCLI11” for linked server

I have two SQL Servers on two different machines somewhere in the cloud (maybe Azure). One is Microsoft SQL Server 2012 (SP3-CU10) (KB4025925) - 11.0.6607.3 (X64) Jul 8 2017 16:43:40 Copyright (c) ...
0
votes
1answer
16 views

how to display running count of records in query

I am working on SQL SERVER 2012, and I have been trying to figure out how to include a running count of records in a group by statement. For example, the query would look something like: SELECT ...

1
2 3 4 5
90