Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [sql-server]

Microsoft SQL Server is a relational database management system (RDBMS). Use this tag for all Microsoft SQL Server editions including Compact, Express, Azure, Fast-track, APS (formerly PDW) and Azure SQL DW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, Oracle, etc.). Do not use this tag for issues on software and mobile development, unless it is directly related to the database.

0 votes
0 answers
17 views

SQL Scan vs Seek when using OR in where criteria

Consider the following two queries from the AdventureWorks database. The where criteria is entirely on indexed columns. If you use OR criteria both tables get a full table scan on them. In the second ...
1 vote
0 answers
10 views

Role permissions to trigger SQL Server Service Broker

We have a Service Broker that listens for changes to the database and then sends messages to a queue based on the changed data. This works if the logged in user is has a server role of sysadmin or ...
1 vote
0 answers
17 views

Msg 5161: An unexpected file id was encountered after server restore [closed]

I'm aware of a similar question asked here, but it was never answered; After the Crowdstrike incident, one of my SQL VMs was blessed with a corrupted registry. I fixed the drive via attaching the OS ...
0 votes
0 answers
54 views

Get the no.of records Inserted in last 10 days

In my table I didn't have primary key and forgot to add timestamp column. Now I would need to find the records with date time of insertion in last 10 days. Is there a way to find this? If yes then how?...
0 votes
0 answers
11 views

Is it possible to get md5 of the entire table in SQL Server? E.g., by hashbytes

We want to get the md5 checksum of the entire table to verify the consistency of data, e.g. using the hashbytes() function of SQL Server. As an intermediate step in the proof of concept, we figured ...
364 votes
6 answers
527k views

Format SQL in SQL Server Management Studio

In Visual Studio & other IDEs, you can easily auto format your code with a keyboard shortcut, through the menu, or automatically as you type. I was wondering if there is yet a way to enable this ...
0 votes
1 answer
899 views

Append polygon into multipolygon

Currently, when I save a multipolygon, I do this by combining all the polygons I have into one string before I save them into one cell. Worked like a charm so far. However, I'm starting to get bigger ...
-3 votes
0 answers
22 views

Custom SQL Server datediff function with same logic as databricks [duplicate]

So apparently datediff on Databricks has different behavior compared to SQL Server. One month is considered elapsed when the calendar month has increased and the calendar day and time is equal or ...
0 votes
0 answers
35 views

How to create a file in another server using T-SQL

I have 2 servers; one server hosts a SQL Server (which is a Windows machine), and the other one is a linux system. I want to export the data from the SQL Server instance to linux system. While I was ...
4 votes
5 answers
503 views

How can I convert values from one column into a quoted, comma-separated list?

Hi I am using SQLServer2008. In my table there is one field 'Code'. When i write query select Code from Table1 then it gives below output Code ---- 9 8 7 6 5 10 31 and my required ...
-3 votes
0 answers
53 views

Why am I getting the wrong value or NULL after doing left joins? [closed]

I have a table called Persons with an ID column. I have another table called Cases which has an ID, another PersonID, and the date that the case was made. I have a third table called PersonsCases, ...
3 votes
4 answers
12k views

How to find which Database Roles are associated with a given User?

In SSMS I have a User X and there are Y, Z and P Database Roles available, how may I check what roles are added to a user X? What have I tried: In SSMS right click on database -> properties -> ...
0 votes
0 answers
16 views

Azure Pipeline timeout with testcontainers

I have a similar issue as this: Testcontainers: Azure pipeline test stage reach timeout of 1hour I would have commented there but I can't comment because I don't have 50 reputation. It's the same case,...
102 votes
2 answers
351k views

Last executed queries for a specific database

I know how to get the last executed queries using the following SQL in SSMS - SELECT deqs.last_execution_time AS [Time], dest.text AS [Query] FROM sys.dm_exec_query_stats AS deqs CROSS APPLY sys....
-1 votes
0 answers
52 views

Improve performance or change query so it can be an indexed view

We have this query in a non-indexed view in SQL Server 2022. It's used everywhere and I'm trying to improve the performance. A lot of queries we use elsewhere join to it. My thought was whether there'...

15 30 50 per page
1
2 3 4 5
22379