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
2answers
37 views

Which way is a better structure for users table in a shopping project - SQL Server

I think it will be faster, but if its a better database design and structure I'm not sure, Should I create a field in Users table which indicates if the user has a shopping cart or not, and only if ...
-3
votes
0answers
18 views

how to run script file generated in sql sever 2014 in Sql Server 2017 or 2019? [closed]

I'm using SQL Server 2014 and I have database in it. I generate script file but when I try to execute in SQL Server 2019 it cant executed. How I can execute older version script file of SQL server in ...
1
vote
0answers
56 views

Server is configured for Integrated authentication only [closed]

I'm new to SQL server. I have a very basic idea about it. And on a recent application I needed to use SQL server. But I have to access the db stored on the another computer. So I changed the SQL ...
1
vote
1answer
50 views

Can I downgrade from SQL Server 2017 CU25 to CU20?

New instance of SQL Server 2017. I chose to install up to CU25 during the initial installation. Been using the database for a few months, but it seems to have a memory leak when using memory-optimized ...
-1
votes
1answer
53 views

Getting Results from Previous Query Output

I'm in school and trying to learn a concept of getting results from a previous query. I can share what I have so far. So, basically I have two different databases on the same server (Server1) with the ...
10
votes
1answer
902 views

Seemingly identical WHERE clauses returning different results

I have a table named [User]. Below is a simple query to find one user from the table: SELECT [Username] ,[FirstName] ,[LastName] ,[EmailAddress] ,[IsStaff] ,[ExternalID] ...
3
votes
1answer
58 views

Fill in missing periods in between periods where missing transactions

With a lof of help from the community I have been able to create a query that automatically adds new rows for project with accumulated number from previous row if there are no transactions. ...
0
votes
1answer
25 views

How to open a sqlserver FileStream Feature without a restart of the sqlserver instance service?

I've seen replying for how to enable the filestream feature by a sql statement. but when the feature is opened, how to restart the sqlserver service instance to made it effects?
0
votes
1answer
48 views

What is the best way to check performance for table vs view?

Could you please advice what is the best solution for compare performance of query for Table vs View. I mean have have two databases on same server (SQL Server 2016). Both include same data but in ...
-1
votes
0answers
31 views

ASP.Net Core Identity EF 5.0 restore only users to database [closed]

My question is hereby reposted since it was suggested that it was in line with this forum. I am using the Microsoft.AspNetCore.Identity.EntityFramework in my Blazor Server Project and have customized ...
0
votes
1answer
64 views

In SQL Server, is there a way to pivot on an unknown number columns WITHOUT using dynamic SQL?

Essentially if we have this: create table #temp ([key] nchar, [value] nvarchar(2)); insert #temp ([key], [value]) values ('a', '1'), ('b', '2'), ... ...
0
votes
1answer
41 views

SQL Server - Create new database without model tables

In SQL Server 2016, is it possible to create a new (empty) database without including any tables from the model system DB?
1
vote
2answers
41 views

How to flag one record (row) as primary, if there are more than one record per ID?

I have a table like below that's used to track contact information for our vendors. The 'IsPrimary' flag is normally supposed to be AP but another email can be set as the primary if we don't have the ...
0
votes
2answers
76 views

tune WHERE datediff

My query is running a little slow and I think it's because of the where datediff function. WHERE DateDiff(minute, TB1.stDate, getdate()) > 50 (With this approach at least is using the index I ...
3
votes
1answer
89 views

sp_HumanEvents @event_type = N'blocking' and logging job help needed

Those who use excellent sp_HumanEvents, maybe the author himself, please help me understand something I am missing (cause of my stupidity). #1 When monitoring blocking, blocked process threshold must ...
1
vote
2answers
54 views

SQL Server 2019 - using MSA as a proxy account

I'm thinking about using MSA (or gMSA) as proxies inside my SQL Server instances. This proxies would be used for example for running SSIS packages or xp_cmdshell command. But based on what I've ...
2
votes
1answer
124 views

Does each member of execution plan run in its entirety before the next execution starts?

I am looking at an execution plan and reading it from right to left. Example: 1<-2<-3<-4 ^ |_5 So 4 and 5 execute in parallel. When both are fully done, then 3 executes in its ...
-1
votes
2answers
52 views

What does the process shown in the deadlock graph represent?

I have a windows application that is used by multiple users, often there are deadlocks in the database related to lock resources. Looking at the deadlock graph I see 2 processes and 2 resources, ...
5
votes
1answer
72 views

How to check Query Store settings on model database?

Query Store can be enabled on the model database and ensures that every new database has the same settings as the model database. The GUI option is missing But it can be enabled using TSQL ALTER ...
0
votes
1answer
31 views

Get data between nth occurrence of two characters

I'm trying to extract a certain data from below two examples and can't seems to get it. From first string I need this value 99068001 and from second string I need this value 42135001 I think it would ...
0
votes
1answer
44 views

How to capture the exact SQL text involved in deadlock (locks) using extended events?

I have setup extended event session with the following event: xml_deadlock_report When I look at the deadlock graph, it shows me the processes asking or requesting for the resource, and the type of ...
-1
votes
1answer
33 views

Can latch waits cause deadlock with error mentioning `lock resources`? [closed]

SQL server deadlocks usually happen due to lock resources. Other causes are memory, etc. When the deadlock error message clearly states that the deadlock is due to lock resources, then does it always ...
0
votes
1answer
42 views

New login created in single user-mode does not exist in multi-user mode

When I create a new login in single-user mode I can see the user was created. When I restart the server and connect via SSMS the login does not exist. Details: I'm running MS SQLEXPRESS 2008 R2 and I ...
0
votes
1answer
42 views

Recalculate "Estimated I/O Cost" without exporting and importing database

I have the following query: SELECT [t].[Key], SUM([t].[ValueA]), SUM([t].[ValueB]) FROM [MyTable] AS [t] GROUP BY [t].[Key] This table had an nvarchar column with value lengths of 2000 characters (I ...
1
vote
0answers
34 views

Tracking Read/Write latency for SQL server on linux

Hello i want to track SQL server read/write latency for the SQL servers i monitor running on linux host. I checked and found disk related metrics would not work here for linux if fetched from sys....
0
votes
1answer
46 views

Select rows where result appears more than once

I have been looking all over StackExchange, testing various methods listed here, without any success. I need to SELECT only users that have multiple sessions. This is my beginning SELECT statement: ...
1
vote
1answer
62 views

Improve performance searching nvarchar values on varchar column

I have a table with order data in an azure sql database. Our web developers (using django) consistently have queries that look like... SELECT col_one, col_two from order_headers where order_number = ...
-3
votes
1answer
33 views

How to return greater than 1, but also show 1

I am running the below, which gives me what I need, but I also want it to show data for seq 1 if there is a seq 2, if there is no seq 2 I do not want it to return the data for seq 1. So basically i ...
-1
votes
2answers
45 views

Does SQL server share data pages?

I am trying to understand more about how data is allocated to the 8KB data page: Can the same page be shared with rows from other databases? Can the same page be shared with rows from other tables?
0
votes
0answers
17 views

Class not registered error when trying to connect to SSIS in SSMS

Please help! I'm trying to connect to a SQL 2012 version of SSIS but get the following error message. I have tried using both an older and newer version of SSMS. I could download and try a SQL 2012 ...
3
votes
2answers
115 views

How does SQL Server handle parallel UPDATE transaction that prospectively would result into rows that would match the WHERE clause of 1st transaction?

Suppose I have the following case: Transaction 1 does UPDATE using a WHERE clause and has not yet committed. UPDATE TBL SET VAL1=10 WHERE VAL2=100 Transaction 2 tries to SELECT rows that are not part ...
-1
votes
0answers
37 views

How to compress and reduce file size of DB backup [closed]

We are facing size issue (large size issue) for database backup. We tried below ways to reduce larger size issue. Compress backup Option compress done in specified database Overwrite all existing ...
3
votes
2answers
543 views

Can indexing be a solution to SQL deadlocks that are caused due to lock resources?

This question pertains purely to deadlock caused due to lock resources. I am reading this article: Using a Clustered Index to Solve a SQL Server Deadlock Issue They have explained how adding ...
-1
votes
0answers
29 views

The SQL Server (MSSQLSERVER) service terminated with the following service-specific error: [closed]

The SQL Server (MSSQLSERVER) service terminated with the following service-specific error: The specified resource name cannot be found in the image file.
2
votes
1answer
52 views

Does sql server lock entire table and keep it locked when the table is heap?

Irrespective of the where clause; When table is heap (no clustered indexes) then does a select query make sql server to lock all rows until it has finished reading all the rows? Where as in case of ...
0
votes
1answer
27 views

ODBC connection fails when running with SQL Server Agent

I've changed an SSIS package to use a 64-bit ODBC connection instead of 32-bit. After deployment it works fine when executing the package but when running a SQL Server Agent job with the package it ...
1
vote
0answers
26 views

Cross domain authentication - 'The target principal name is incorrect. Cannot generate SSPI context'

I have problem with windows authentication. I have two domains (Lets say A and B), and server which is at the domain A. It is an default instance on the server and it uses AD account as an service ...
1
vote
0answers
61 views

How to estimate the nonclustered index size before its creation?

I created two scenarios and expected to see the same result but the results were noticeably different. I would like to know where I did wrong. Scenario 1 Create table mytable1 with clustered index and ...
2
votes
2answers
258 views

Reduce the size of a primary key Index

I'm using Azure SQL DB and noticed that one of my largest databases appears to have a primary key index with a total size of 6Gb. It's a clustered index on a uniqueidentifier. However, the total rows ...
0
votes
1answer
35 views

Do trace flags 1204 and 1222 give any more information than available via the xml_deadlock_report event in Extended Events?

I am exploring deadlock detection approaches. Trace flags 1204 and 1222 Extended events (xml_deadlock_report) Do the trace flags contain any more data than what is available via the Extended Events ...
0
votes
2answers
45 views

Restore fails in single mode because exclusive access cannot be obtained

We have a script that runs every night, this is the relevant part of the script: ---- Restore DB from file system print '' print '----------------------------------------------' print 'Restoring ...
-4
votes
1answer
45 views

Updating column value across all SQL server versions [closed]

I have a simple table with 3 columns Installed by - some login name Installed date - Date when bunch of scripts were run with any changes as part of that package Version - version number when release ...
0
votes
1answer
50 views

Fill down if no value in period, autoknow the periods

I have created a query that gets the running total from my general ledger by period. This works fine, however as soon as there are no transasctions in a period, my query will return noting in that ...
0
votes
1answer
44 views

how can resolve a cyclic redundancy check sql

i need to restore a database but i have a strong problem, please look the photo, is a strange error, please helpme
2
votes
2answers
71 views

How do I resolve lock issue when replicating a table with over 16Billion records

I have two SQL Server databases that I am trying to replicate. I am able to replicate small tables without any issues. However I have a table with over 16 Billion rows that is quite problematic. I am ...
0
votes
1answer
49 views

Is there any option to get actual execution plan as xml value to insert do different table?

Do you know If there is any option to get actual execution plan and insert this plan to another table ? I would like to have table with history of actual plans.
-1
votes
0answers
35 views

Find all sql jobs to be run within a time window [duplicate]

My question is: Assume today is Monday, how can I find all jobs that are scheduled to run between 5pm and 6pm next Friday on a sql server instance? It seems a very complex calculation due to the ...
0
votes
2answers
33 views

Finding groups which have two values in another column

Given the following sample rows: MTYPE RNO VAL S 1 V1 S 1 V2 S 1 V3 R 1 V4 S 2 V5 S 2 V6 R 3 V7 R 3 V8 How can I list groups of RNO which has both 'R' ...
1
vote
0answers
47 views

What is the best way to have actual execution plan and IO stats as values to insert?

We have idea to create procedure which will test performance of query and insert specific information associated with executed query to table with test performance history ([dbo].[TestHistory]. We ...
-2
votes
1answer
62 views

Group by on three tables as one master table and two detail tables

I.tblOwnerDetails Ownerid ownername 1 Abc 2 Xyz 3 Pqr II.tblListMaster Listid Listname 1 List1 2 List2 III.tblListDetails Detailid Listid Ownerid 1 1 1 2 1 2 3 2 1 4 3 1 IV.tblTagMaster ...