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
-3 votes
0 answers
29 views

How to save a SQL diagram as Pdf?

I tried to save the diagram as an image using the "copy to Clipboared" function and then paste it in Paint and Word. But only the tables are copied and not the content ( the attributes) of ...
user avatar
  • 1
0 votes
0 answers
36 views

Alter Trace (SQL Server Profiler) security risks?

SQL Server database -- a read only node specifically (not exactly sure how that works). Our database keeps crashing due to memory issues - various error messages indicate this. It's hard to tell if it'...
user avatar
  • 1,493
0 votes
1 answer
70 views

SQL Server can't create sysname type colunmn

I'm trying to create a new table based on an existing table. In the existing one, there are two columns that are sysname data type. But when I'm trying to create the new one with sysname, SSMS shows ...
user avatar
0 votes
0 answers
31 views

SQL Failover Cluster - 'SQL Server' service terminating because of 'fatal exception c06d007e'

I have an SQL Failover cluster (2016) with 2 VMs. The 'SQL Server' service was down when seen from 'Failover Cluster Manager'. On checking the Event Viewer logs, the SQL Server showed below error. ...
user avatar
0 votes
0 answers
26 views

What is the correct type in sys.objects for an external table against another SQL Server

In SQL Server 2019 we use Polybase to create External tables pointing at tables on another SQL Server. When I look at these external tables in sys.objects, they have the type U , meaning USER_TABLE. ...
user avatar
  • 563
0 votes
0 answers
36 views

Deadlock with Tablock on table with clustered columnstore index and partitions

I have table with clustered columnstore index and partitions When i`m try to insert data into it with tablock hint, query got a deadlock. INSERT INTO Cohort_Staging WITH (TABLOCK) ( [...
user avatar
2 votes
2 answers
60 views

Optimal Indexing Strategy for Datawarehouse and Data Lake Updates

We have a sql server database we use as a data lake and a datawarehouse. Each table in the database has some standardized definition as we are at 600 or so tables now, so maintenance needs to be ...
user avatar
  • 148
-2 votes
2 answers
62 views

Is the SQL dialect in SQL Server closer to Oracle or to Postgres?

There is an existing application that supports having its data in an Oracle database or a Postgres database, through JDBC. The tables and data are the same, but it can be installed in any of them, to ...
user avatar
  • 112
-2 votes
0 answers
16 views

Migrate RDS AWS DBS to ORACLE CLOUD [closed]

What is the best method/ tools to migrate from RDS AWS DB(PostgreSQL, MySQL Community, SQL Server Standard Edition) to Oracle Cloud Infrastructure with Zero Down time ?
user avatar
1 vote
0 answers
18 views

Sustained substantial increase in Logical Writes for all plans & dbs on an Azure Managed Instance

We habe a managed instance with a 12 or so dbs supporting the same application across 2x customers. This has been running find on a 4-core sql managed instance, but at almost exactly midnight local ...
user avatar
0 votes
1 answer
35 views

Create NonClustered online vs Create NonClustered offline

I understand that Nonclustered index uses bigger space than clustered index. Azure SQL provides option to create Nonclustered index using both ONLINE = { ON | OFF }. How is the NCI creation different ...
user avatar
3 votes
2 answers
171 views

Can't restore a specific SQL Server database in Docker

I create a SQL Server in Docker and I can successfully connect to it from SQL Server Management Studio. I copy the backup file mybackup.bak from my server to the Docker SQL container path /var/opt/...
user avatar
-1 votes
1 answer
44 views

What characters are rejected during this check constraint clause in a SQL Server stored procedure?

I tried to import a record with a semicolon in the addr field. Once I removed the semicolon from the import file, the following error went away: Database error occurred SQLSATE = 23000 [Microsoft][...
user avatar
  • 147
0 votes
1 answer
43 views

Changed Hostname of PC, MSSQL DBs no longer accessible when logged into Management Studio

I had to change hostname to conform to new employer policy. I have about 4 DBs locally in MSSQL lite. They still work. The apps that use them are working just fine. I ran... SELECT @@SERVERNAME AS ...
user avatar
1 vote
1 answer
70 views

Do missing index DMVs work with indexed views?

I've been delving into query store to find the cause of some high CPU usage and found some potential index improvements to some existing indexed views by looking through the plans of the highest CPU ...
user avatar
2 votes
1 answer
57 views

How to rollback to earlier SQL Server version without data loss after SQL Server upgrade

We are planning for SQL Server 2019 upgrade from SQL Server 2014 version. One of the requirement from the business owners is that we should be able to fall back to earlier version without data loss ...
user avatar
  • 21
0 votes
1 answer
48 views

MSSQL Listener issues

I have a problem with my SQL production cluster that I am really struggling to figure out. Recently, we had to add a secondary NIC to our production cluster for SQL because in AWS land, most instance ...
user avatar
0 votes
1 answer
34 views

exec limited to 4000 characters?

trying to execute this script gives only the first select as a result declare @sp nvarchar(max) select @sp = concat(N'select 1 ', replicate('-', 5000), char(13) + char(10), N'select 2') exec (@sp) ...
user avatar
0 votes
2 answers
90 views

SQL Query execution with IN statement

I didn't get proper result Below is my tables values : DECLARE @Id as nvarchar(MAX) = N'''2'',''3''' DECLARE @spparams as nvarchar(max) =N'@Id as nvarchar(max)' EXEC sp_executesql N'select * from ...
user avatar
1 vote
2 answers
52 views

Fill in missing values without double dip to data table

Suppose there are two lists of categories and then a data table with combinations of those categories, along with various other values. Suppose that there can only be one instance of any category ...
user avatar
  • 1,811
4 votes
1 answer
82 views

What is the current state (2022) of using UDFs in a CHECK constraint in SQL Server?

SQL Server allows the use of User-Defined Functions (UDFs) in CHECK constraints - which has a number of use-cases - which I won't get into - but I was recently faced with implementing a non-trivial ...
user avatar
  • 448
0 votes
1 answer
82 views

What is the fastest way to extract numeric characters from a field using TSQL?

Have a large table with varchar(100) - OrderNum field values like so: "BO2003056-2" Need to extract all numeric characters from this field for subsequent joins to another table. Ex: "...
user avatar
0 votes
1 answer
61 views

When Insert Press Name Tech Id Take Wrong Number Where Press Name Exist?

I work on SQL server 2017 I have table #Pressfeature as below create table #Pressfeature ( PartId int, PressName varchar(300), TechId int ) insert into #Pressfeature(PartId,PressName,...
user avatar
-4 votes
1 answer
41 views

please explain the query

This looks like what I need as well. However, not being proficient in query making sense out of some of this.. so can you please clarify some things for me? ;WITH x AS <--- is this a comment? ( ...
user avatar
  • 1
0 votes
1 answer
33 views

How to merge filegroups?

Now I have a database with the following files: PRIMARY FILEGROUP 1.ldf SECONDARY FILEGROUP 1.ndf 2.ndf 3.ndf I need to merge it into the one primary filegroup with one file. Files from secondary ...
user avatar
0 votes
1 answer
42 views

Can we delete data using SQL job and insert data into the same table at the same time from another application

I have created one SQL job and it is executing a stored procedure to delete data from the table at a specific time. But at the same time, if anyone will try to insert a record in that same table from ...
user avatar
0 votes
0 answers
12 views

Error en DMS AWS "base de datos rdsadmin no existe" moviendo desde sqlserver on premise a AWS S3 [migrated]

Actualmente tengo una base de datos réplica on premise sql server en un data center. Además tengo un DMS en mi cuenta de AWS que extrae datos desde la bd réplica y los mueve a un bucket de AWS S3. Por ...
user avatar
0 votes
0 answers
20 views

ML feature table for transactions in last 7 days

I have a database with the following schema : CREATE TABLE transactions ( transaction_id UUID, date DATE, user_id UUID, is_blocked BOOL, transaction_amount INTEGER, transaction_category_id INTEGER ); ...
user avatar
  • 1
2 votes
1 answer
46 views

100 GB SQL Server database stuck on "Restoring..." after restoring from backup

I've restored lots of SQL Server databases before but none quite this large. I got a 100GB+ .bak file that I restored recently but has been stuck with this "restoring" flag for about a half ...
user avatar
0 votes
3 answers
74 views

Rollback a transaction using single thread/multi thread

Would it be possible to rollback a transaction using a single thread? I tried to find an answer to this question, but I couldn't find one that provided references. I read about rollback mechanisms. ...
user avatar
1 vote
3 answers
294 views

How Does SQL (In my case SQL Server) Evaluate a Unique Constraint On Multiple Columns?

Given the following table CREATE TABLE example ( id int NOT NULL IDENTITY(1,1), strA NVARCHAR(10) NULL, strB NVARCHAR(10) NULL, CONSTRAINT [pk_id] PRIMARY KEY (id) CONSTRAINT [...
user avatar
-1 votes
0 answers
27 views

Visual Studio database settings compatibility level

Our database is SQL Server 2017, our sql server itself is SQL Server 2017 (version 14) 3 of the colleagues can choose up until SQL Server 2017 in the compatibility level in the database settings ...
user avatar
4 votes
1 answer
169 views

SQL Server execution XML plan cut off in length

I am running the following standard query to retrieve the XML execution plan for queries that I ran on my SQL Server via command line. SELECT pl.query_plan FROM sys.dm_exec_cached_plans ep CROSS APPLY ...
user avatar
  • 141
0 votes
0 answers
86 views

issue with MSSQL fulltext search

original table contains json, but i've stripped it down to the table below: id json 1 "name":"one.it.two" 2 "name": "one.it.two" difference between the two ...
user avatar
  • 1
-2 votes
0 answers
93 views

Can we get deleted records back in SQL Server without backup

I have deleted some records accidentally. and I tried to retrieve it with the below query, SELECT [Current LSN],[Transaction ID], Operation, Context, AllocUnitName FROM fn_dblog(NULL, NULL) WHERE ...
user avatar
0 votes
2 answers
92 views

Take Backup of a Database without the Corrupted rows

I have DB of size 170GB. One of the table has 339500 rows out of which around 2000 rows are corrupted. When I tried backing up the database I get "Backup with 'Checksum' gave error" SQL ...
user avatar
-3 votes
2 answers
71 views

Why not reduce the database log file size with shrink?

I use SQL server database. To reduce the database log file I set the recovery model of the database to simple and then Shrink database but the log file does not get the effect. What is problem?
user avatar
-2 votes
1 answer
45 views

SQL Server High Availability Dashboard comes up blank when accessed. Is there a fix for this?

Recently whenever I access my SQL Server High Availability Dashboard, it comes up blank and I am not able to see the databases and the synchronization between the servers. Is there a solution to ...
user avatar
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
20 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,367
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