Questions tagged [sql-server]

All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag, like sql-server-2016, since it is often relevant to the question.

Filter by
Sorted by
Tagged with
0 votes
1 answer
55 views

Replace %S with Feature Value on Feature String Based on Feature Name and Partid

I need to write a select statement that will replace a %S string in the FeatureString column with the actual values stored in the same table for a given PartID. With the following example data: +------...
user avatar
0 votes
0 answers
30 views

Group datetimes by "session" logic (gap between events) [duplicate]

There are a couple similar questions out there -- this is NOT about grouping things by 30 minute intervals or similar. This question is similar to Google Analytics logic. A "session" is ...
user avatar
  • 1,493
0 votes
1 answer
39 views

New DB: Best settings for a BI staging area

I would like to know if there are specific recommended settings when creating a new DB (in SQL Server) which will serve as a staging area DB for BI data flow. In terms of DB use behavior this means: ...
user avatar
  • 9
1 vote
1 answer
88 views

Cannot connect to SQL Server, cannot start SQLEXPRESS service

There are 2 issues at the same time. I cannot connect to the database (SQL Server 2012) using SSMS - I'm getting error 1225 I cannot start the SQLEXPRESS service - getting error 3414 Earlier last ...
user avatar
0 votes
1 answer
39 views

Eliminate a row which repeat same values vise versa in two columns like Col A = 1 ,Col B = 2 then next row Col A = 2 ,Col B = 1

from the above table I need records having (F_ID 101,302,both 599 and 444) excluding 201. The query should eliminate values which interchange and form another row. Like S_ID 201 belongs to F_ID 101 ...
user avatar
0 votes
0 answers
35 views

Query to retrieve queries registers run by users in sql server database

I use a sql server 2019 and recently had a problem with the database tables and data. I'm want to set up a query that returns to me the last 10 commands executed in the bank with the priority of the ...
user avatar
0 votes
0 answers
27 views

Simplifying Grouping Sets SQL Server

I need to do the following group by clause with grouping sets. Is there a way to simplify it? grouping sets ( [O].[orderId], [OD].[productId], [D].[value], ([OD].[...
user avatar
0 votes
0 answers
49 views

Linked Servers - MS SQL Server Migration from 2012 to 2017

I'm preparing migration for whole server SQL Server instance 2012 to 2017 (new project, don't know the old environment in details), but have question here only about the Linked Server. This is the ...
user avatar
0 votes
2 answers
28 views

SQL Report Services on AOAVG

We have 2 SQL Servers in a SQL Server 2016 AOAVG. When we fail over to the secondary replica, the reports do not work. Am I right in thinking that this is because we need to stop the SQL Server ...
user avatar
0 votes
1 answer
21 views

Should I backup and restore the SMK when performing a server upgrade and migration?

I understand that the SMK is used to encrypt sensitive data like passwords in the linked server configuration. Hence when I migrate or upgrade the sql server to another computer, then I assume I ...
user avatar
  • 2,371
0 votes
2 answers
52 views

In my query plan - multiple nodes say that their cost is 100%

In this query plan: https://www.brentozar.com/pastetheplan/?id=HydtQjsO5 ...multiple nodes have a cost of 100%. How does this happen? How do you figure out where to start optimizing when so many nodes ...
user avatar
  • 171
7 votes
1 answer
1k views

Memory Requirements for SQL Server

We have a machine with 256 GB RAM. Max server memory for the SQL Server is set to 180 GB. Out of 180 GB, SQL Server typically uses: Database Cache memory - ~ 140-150 GB Plan Cache - ~ 10 GB Stolen ...
user avatar
0 votes
0 answers
16 views

SSRS Security settings using ReportService2010 - .GetPolicies InheritParent value

I need to add permissions on lots of folders, I was looking into using ReportService2010, but I have doubt regarding inheritance of security settings. In all examples I found online they are using: $...
user avatar
0 votes
1 answer
46 views

No column name was specified for column 1 of 'd'

I am trying to get some data from 3 tables in SQL Server, but getting an error. I have created a fiddle with similar structure and sample data Based on the data in tblData, I am trying to get the ...
user avatar
  • 135
0 votes
0 answers
25 views

insert missing records into table has sequence id

I am using SQL server 2019, enterprise-production- Before the deployment, I took backup for the DB Let's call it BK1 After the deployment, we had to rollback Before rollback, I took another backup ...
user avatar
  • 31
0 votes
1 answer
55 views

[ SQL Error 15173 ]Unable to drop a SQL Server Login (Login is a AD Group)

Recently I have added a SQL Server Login and later want to drop it. But I am seeing below issue, can you please see what is my miss here. USE [master] GO /****** Object: Login [] Script Date: 5-6-...
user avatar
0 votes
1 answer
41 views

SQL Database Replication

I have requirement with below for SQL database replication. I have two separate SQL database servers on same network, one will be used as primary and another one as secondary. Primary is a central ...
user avatar
-3 votes
2 answers
34 views

How to get numbers that have IE in case of data type float?

I work on sql server 2017 i face issue when save data on float data type it display as IE so how to get data only that display as IE on float data type CREATE TABLE #TestTable ( ...
user avatar
0 votes
0 answers
44 views

Place multiple related records into single table with extra fields INTO SPECIFIC FIELDS

I am using code supplied below by J.D. I added a WHERE clause to limit my search to specific values in the STATUS field. But when I get the results it displays them as first come first serve. I am ...
user avatar
2 votes
1 answer
61 views

Why does my application have over 20,000 idle (sleeping) connections in SQL Server?

I have an analytics application running with .NET 6 in a Linux Kubernetes container. It receives http messages and logs them. For my data layer, I'm using the Microsoft.Data.SqlClient v4.1.0 library, ...
user avatar
0 votes
1 answer
31 views

SQL Server Upgrade + BPE

One of the SQL instance has BPE( buffer pool extension) enabled. Would this have an impact ( or any issues ) if instance is upgraded from SQL 2014 to SQL 2019. I went through the MS docs and does not ...
user avatar
0 votes
1 answer
66 views

Db file and transaction log segregation in SAN

I understand that if we are using HDD then it will be advisable to store the data file and transaction log on different drives (which point to different disks). However, if the server is using SAN, ...
user avatar
2 votes
0 answers
23 views

Lined Server - Cannot create an instance of OLE DB provider "IBMDADB2.DB2COPY2" for linked server "MYDB2"

I would like to create Linked Server from SQL Server 2016 on Windows to Db2 v11.5.7 on Linux/x86. I created linked Server using Microsoft OLE DB Provider for DB2 and it works fine. Now I would like to ...
user avatar
  • 97
-2 votes
0 answers
33 views

Group data like MUI dataGridPro Grouping Feature

I am currently trying to select data from database using sql to display data on table which is same as MUIGridPro table grouping feature. Input Data Expected Output if group by one column (col3) ...
user avatar
1 vote
1 answer
31 views

CREATE LOGIN is not recognised by a trigger it password is empty

Accordingly to company policy I have to prevent creating SQL logins with CHECK_POLICY=OFF setting, so I've created a trigger: CREATE TRIGGER [create_or_alter_login] ON ALL SERVER FOR CREATE_LOGIN, ...
user avatar
0 votes
2 answers
430 views

Consistent backup of multiple MS SQL databases

We have ~30 DBs on MS SQL server and unfortunatelly DBs rely on each others data, do cross-db joins and system fails on inconsistency of data. This sounds terrible, and requires fixing ASAP, but i'm ...
user avatar
  • 141
0 votes
1 answer
41 views

Place multiple related records into single table with extra fields

I have these two tables below with a Key field of BOVA which forms a many to one relationship. I am trying to join these 2 tables but create additional fields to house the numerous STATUS fields. ...
user avatar
1 vote
1 answer
43 views

Potentially Improper Row Count Read in Parallel Bitmap Hash Match Plan

I am trying to determine whether or not this is an execution plan reporting bug or an actual feature that is working as intended. In my execution plan, when using MAXDOP 1, I am seeing the entire ...
user avatar
4 votes
0 answers
50 views

Log Backup occasionally blocked by automated update

We have a canary table in each of our databases that our automation updates once a minute. The automation is a sql server agent job that utilizes a cursor to iterate over the databases and then ...
user avatar
  • 2,968
0 votes
1 answer
31 views

Does manual failover of availability group bind an SSL certificate?

I'm trying to find the least intrusive way to bind a new SSL certificate to an Always On Availability Group 3-node cluster. After applying the new certificate, a message appears that SQL Server will ...
user avatar
  • 278
1 vote
2 answers
55 views

Azure SQL - altering MAX DOP value at Database scope level is not taking place

I am trying to change the MAX DOP value for my Azure Managed SQL which currently is set to ZERO. Here is the script I am running: USE [my-sql-db] GO ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP =5 ;...
user avatar
  • 221
0 votes
1 answer
41 views

How to create a reference in a many-to-many relationship with transact SQL?

I am creating my first database using only code (I don't like to use graphical interfaces, I feel that I am not learning to write T-SQL code, it is my personal opinion), I do not know how to create ...
user avatar
0 votes
2 answers
31 views

AWS RDS Sql Server READ_COMMITTED_SNAPSHOT

We're currently running Multi-AZ SQL SERVER (Mirroring) and would like to turn READ_COMMITTED_SNAPSHOT on. It doesn't look like this option is available in the parameter group or rdsadmin stored ...
user avatar
4 votes
1 answer
264 views

Why does CURSOR_STATUS return unexpected results for an output cursor inside the stored procedure that created it?

I have a stored procedure that has an output parameter of the CURSOR VARYING type. I would like to verify that the output cursor can be used by the code that called the stored procedure. It seemed ...
user avatar
  • 30.5k
3 votes
0 answers
30 views

Primary filegroup full on a Read-Only database in SQL and we need to change access

I came across a strange scenario in our production server today that business wanted to add a new Login to be implemented for a read-only database. So we tried to make the Database to Read-Write mode, ...
user avatar
0 votes
0 answers
19 views

Migration SQL managed Instance DB to another tenant SQL MI

I am stuck with a SQL migration between 2 tenants. Any help will be really appreciated.  There is one SQL Server managed instance TDE enabled is sitting in one tenant and we have to move the same to a ...
user avatar
  • 1
1 vote
1 answer
60 views

Terminology for Specific Kind of One-to-Many Relationship

This question regards how a one-to-many row might "belong" to a different row and what exactly to call it. I might be asking for a term that does not exist. Please see the below two tables. ...
user avatar
0 votes
1 answer
38 views

MS SQL Server 2016 SP3 upgrade failing

I tried to apply the SP3 on one of my SQL Server 2016 DB server, and it kept failing with the below error. Error description: The installer has encountered an unexpected error. The error code is 2203....
user avatar
10 votes
0 answers
202 views

Has SQL Server not Killed a Deadlock?

I have encountered a situation where a user has run something in one of our applications which runs a stored procedure. The stored procedure does a few bits of logging (INSERTing to a log table) and ...
user avatar
  • 1,379
0 votes
0 answers
32 views

Moving SQL database with FCI to AWS

We have a MSSQL database which has two nodes and is using Always On FCI for High Availability purpose at our on-premise location. As most of you aware FCI SQL requires the two nodes to share the same ...
user avatar
  • 200
0 votes
1 answer
52 views

Trigger execution order after delete

Let's say I have two tables, one called ParentTable, and another called ChildTable, with a one-to-many relationship, where one Parent may have many Children. I'm creating an AFTER DELETE trigger on ...
user avatar
  • 139
2 votes
1 answer
115 views

Diff backup fails with error 3035 but log backup succeeds

We have a SQL Server 2014 Enterprise where the DIFF backups fail. This is the error message we get: Msg 3035, Level 16, State 1, Server sqltest, Line 1 Cannot perform a differential backup for ...
user avatar
7 votes
2 answers
648 views

ReadOnly queries on secondary server do not return correct values

I have two servers A and B. Both are in an Always On Group. The B server is configured for ReadOnly requests. This works fine so far, but recently there is a problem for queries for a service. The ...
user avatar
5 votes
1 answer
122 views

Extended event - slow queries and waits

I have an extended event which filters on my slow queries. I have created the following script for it. CREATE EVENT SESSION [SlowQueriesAndStatementsLargerThan3Seconds] ON SERVER ADD EVENT sqlserver....
user avatar
0 votes
0 answers
51 views

Unable to configure SQL Reporting Services to use Kerberos

We are trying to enable Kerberos with our SQL Server Reporting Services reports manager website (for ex, instructions in the article "Configure Windows Authentication on the Report Server") ...
user avatar
-1 votes
2 answers
111 views

Does ASYNC_NETWORK_IO wait types result in thread locking until entire result is consumed by client application?

ASYNC_NETWORK_IO wait types are mostly caused because the client application cannot process the data that arrives from SQL Server fast enough. As the query executes, and as the results start getting ...
user avatar
  • 2,371
0 votes
1 answer
41 views

What is the relation between renaming the computer and sp_dropserver/sp_addserver?

I have default SQL server instance (not a named instance). have changed the SQL server computer name, and not run the following commands: sp_dropserver 'oldname'; sp_addserver 'newname', 'local'; ...
user avatar
  • 2,371
2 votes
2 answers
1k views

Allocating more memory than is available for the installed SQL Server edition

We have Microsoft SQL Server 2017 (RTM-GDR) (KB4583456) - 14.0.2037.2 (X64) Nov 2 2020 19:19:59 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 &...
user avatar
-1 votes
3 answers
83 views

How to select Max date that is valid?

I have a date as varchar (dont ask why). I need to select Max(date). However, date can be faulty, like 2034-34-34. I would like to select max date that is valid and not greater than today. It's t-sql. ...
user avatar
  • 133
0 votes
1 answer
26 views

Availability Group - Core cluster resources switch to being owned by secondary node after windows patching reboots

Some of our AG clusters (async, manual failover) shift the ownership of their core cluster resources (e.g. cluster IP) from the primary node to the secondary node, which is in a different datacenter, ...
user avatar