Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
32 views

How to set execution timeout in SSMS

I want to stop all the query that exceeds the given execution timeout value of an instance in SSMS. I tried to set the execution timeout in SSMS using multiple methods. Initially, I tried changing the ...
RD Seeker's user avatar
0 votes
0 answers
30 views

SQLAgent high number of handles

We have an Azure VM with SQL Server (SQL Server on Azure Virtual Machines). When investigating small disconnections from our signalR service running on that server we have seen that SQLAGENT.EXE has ...
juFo's user avatar
  • 299
-1 votes
0 answers
42 views

Adverse effects of outdated statistics in a database [closed]

Faced a p1 issue recently due to outdated statistics in one of our DB (~500G). The sql instance was hosted in a i3.xlarge ec2 and 25G out of total 30.5G memory was set as max memory for SQL Server.So ...
udhayan dharmalingam's user avatar
0 votes
0 answers
21 views

How to execute the [sp_removedbreplication] using linked server

I tried this way EXEC [linkedServer].[MASTER].[sys].[sp_removedbreplication] 'databasename' However I received this message Msg 18482, Level 14, State 1, Line 76 Could not connect to server '...
lego con tsijiari's user avatar
0 votes
1 answer
34 views

Records in the dev environment were deleted due to filter in SQL Server replication

I want to create replication in SQL Server and move the records that have changed in the last year to the test environment. Since I added a filter for last 1 year, when replication runs, only records ...
Merve's user avatar
  • 57
3 votes
3 answers
182 views

Enforce non-unique combination of columns, where combination is required

I have the following (and more non-related) columns in my MSSQL database table: Id, ImageUrl and ImageId. The combination of ImageUrl and ImageId can occur multiple times. ImageUrl belongs to ImageId ...
Max's user avatar
  • 139
4 votes
2 answers
463 views

ALTER TABLE ALTER COLUMN <name> failed because one or more objects access this column

Introduction Recently during an update of an application I received the following error message: Msg 5074 Level 16 State 1 Line 1 The statistics 'BreakingStuff' is dependent on column 'TaskText'. Msg ...
John K. N.'s user avatar
  • 17.9k
0 votes
1 answer
29 views

View on a history table - question how implement a view on history table

question about creating a view with history table. I've got a table that i moved old rows to history table, now i would like to delete the data from the main table. Main table : Currency....
dexon's user avatar
  • 47
0 votes
1 answer
34 views

How to upsert in Sql using Merge statement with where clause

CREATE TABLE SourceProducts( ProductID INT, ProductName VARCHAR(50), Price DECIMAL(9,2) ) GO INSERT INTO SourceProducts(ProductID,ProductName, Price) VALUES(1,'...
amit agarwal's user avatar
0 votes
1 answer
36 views

Azure SQL Server Metrics : is 100% CPU percentage is a blocker for all DB operations?

This is with Azure Sql managed Instance, We have observed a case in our database where the CPU percentage is 100% for quite some time but my application are still able to hit & operate over DB, is ...
Manoj's user avatar
  • 1
-1 votes
2 answers
48 views

2x SQL Server 2019 in AlwayOn group - how to remove transaction log [duplicate]

We have a problem with our Microsoft SQL Server 2019. We have 2 servers in an Always On group with one database. Problem is the actual (real) database size which is about 1 GB, but it takes up around ...
user avatar
6 votes
1 answer
198 views

Execution slow in stored procedure; fast when run ad hoc

I am dealing with an issue that I can't seem to solve. I was given this stored procedure that has speed issues. It takes 35 seconds or so. When run adhoc, it completes instantly. This made me think it ...
anakata's user avatar
  • 61
0 votes
1 answer
36 views

SQL Server 2017 not recognizing Oracle driver for Linked server

I would like to connect from my SQL Server 2017 to an Oracle database via Linked server. I installed the Oracle driver from Oracle-Client-for-Microsoft-Tools-64-bit.exe, but the driver does not appear ...
Balazs Kiss's user avatar
0 votes
0 answers
47 views

Connecting to SQL Server from externally with proxy server

I have a server running SQL Server 2022 with a couple of instances. There is the need to grant access to an external supplier working with us on a project. The idea is: the supplier connects to our ...
aganju82's user avatar
-2 votes
0 answers
20 views

Como Crear una base de datos para un condominio? [closed]

¿Existe algún ejemplo de base de datos para gestionar un pequeño condominio? Utilizando SQL Server, con tablas para registrar información de cobros, gastos comunes, recibos a emitir y realizar ...
CREZ's user avatar
  • 1
0 votes
1 answer
36 views

SQL Server Failover Cluster Data Loss on failover

Currently running several databases on an Active/Passive SQL Server 2014 Failover Cluster on Windows Server 2012 R2. Recently there was an event that caused the active server to failover. The failover ...
David Gerst's user avatar
0 votes
1 answer
31 views

SQL Agent Job failing after uninstall of SQLPS and install of the new module

Uninstalled the old PS module and replaced it with the new SQLServer but now third step of system job syspolicy_purge_history, which is a Powershell step, fails with the following message: The error ...
Stackoverflowuser's user avatar
2 votes
1 answer
26 views

Can we take a copy-only backup for filegroups on the SQL Server from a secondary HA replica?

I am getting the below error while executing the script for taking filegroup backups from a secondary replica. Msg 3059, Level 16, State 1, Line 18 This BACKUP or RESTORE command is not supported on ...
user avatar
-1 votes
1 answer
75 views

SQL join query without multiplying results

I've already got 2 select statements that create temp tables for Part A and Part B. Temp tables Part A Location 10001 A 10001 B 10001 C Part B Location 10001 Z 10001 Y I want it then to be ...
AJ Sadler's user avatar
4 votes
1 answer
85 views

Why is my SQL Server prefering to pick one plan over the other when there are 2 executions plans for the same query in the cache?

I have a 2019 SQL Server with a database with 'FORCE PARAMETERIZTION' set to true and a nightly job which does sp_updatestats on it. One of the application has a feature which has two modes, a "...
QFirstLast's user avatar
1 vote
1 answer
19 views

Using custom table definitions in a multi statment table function

I have a custom type and a table, and I want to reuse this as a return result for several table functions. I want to declare the type rather than recreate the definition. So the start of the function ...
user1331548's user avatar
6 votes
1 answer
123 views

Sampled Statistics Percentage Internal Calculation

When SQL Server builds sampled statistics, how is the sampling percentage calculated? For example, updating statistics on the PostId column of the dbo.Votes table in the Stack Overflow 2013 database: ...
Paul White's user avatar
  • 85.8k
0 votes
0 answers
48 views

Could not allocate space for object 'X'.'Y' in database 'Z' because the 'PRIMARY' filegroup is full

I have a limited primary data file(mdf) and an unlimited secondary data file(ndf) in the DBName database. These two data files are on different disks. I get the following error when the index ...
Merve's user avatar
  • 57
0 votes
1 answer
40 views

Handling duplicated data in SQL

I have a tables which are created and populated with millions of rows on a daily basis. There is no ID field, and rows are identified by the unique combination of field values. There is no possibility ...
Luke's user avatar
  • 349
5 votes
2 answers
575 views

Indexed view - Cannot create index because "select list of the view contains an expression on result of aggregate function or grouping column."

I have a fairly simple view I'm trying to index. CREATE OR ALTER VIEW [schema].[IndexedView] WITH SCHEMABINDING AS SELECT SUM(ISNULL([Quantity], 0)) as [Quantity], [Address], [Asset], ...
deadwards's user avatar
  • 113
0 votes
1 answer
63 views

Telling SQL Server about moving the backup files

I moved some backup files to new destination. However, the SQL Server seem to think they are still in their old place. (That is, when I use the SSMS Restore Database wizard, it it still comes up with ...
Yano_of_Queenscastle's user avatar
0 votes
1 answer
63 views

Availability group failover-tempdb

Does anyone know if SQL AG will initiate automatic failover to secondary if tempdb is full in primary ? I believe Database level health detection is only for user database in AG
Mario's user avatar
  • 47
0 votes
1 answer
45 views

Multiples full backup from MS SQL Server all day long

I think this is not the best practice, but on a server I am administering, there is a PowerShell script doing full backups of a Microsoft SQL Server Express Edition instance every X minutes. What ...
Le  Mngr's user avatar
1 vote
0 answers
44 views

Monitoring data exflitration

I've been tasked with coming up with some mechanism that would allow me to detect when a database user queries a certain table in our system and a large result set is returned (say over 1000 rows). ...
Aheho's user avatar
  • 151
0 votes
1 answer
60 views

How to execute complete database script without checks on objects existence

I'm working on a customer data archiving. I created a complete database script to prepare the new database for archiving data with the same DB schema of the production one. At the moment I'm preparing ...
El See's user avatar
  • 1
1 vote
1 answer
41 views

CDC Capture job fails with 'Cannot insert duplicate key row in object cdc.Table_CT' with unique index 'CT Clustered Index'

When the CDC Capture job runs, it fails with this error: Cannot insert duplicate key row in object cdc.Table_CT' with unique index 'CT Clustered Index. This index is a SQL Server CDC created index ...
Pam Moodley's user avatar
0 votes
0 answers
20 views

Connect to a Private SQL Always On Availability group listener with Azure App

We have a fairly standard Azure Webapp - connecting via public IP to a database server which is a VM hosted in Azure. NSG rules etc limit the traffic between the two. The VM hosting the database is ...
RPD's user avatar
  • 31
0 votes
0 answers
55 views

Installing/Repairing SQL Server installation fails

I am installing a local instance of SQL Server. During setup the database engine fails. What others steps can make sure the installation succeeds? What I've tried: Installing two times. Repairing ...
guradio's user avatar
  • 97
2 votes
2 answers
985 views

Is it possible to register two SSL certificates on SQLServer?

In SQLServer 2019, is there a way to install multiple SSL certificates in parallel? I have the following situation: The division the server belongs to was sold and therefore new DNS aliases were ...
Christoph's user avatar
  • 123
6 votes
1 answer
371 views

What does SQL Server's Error Log actually log?

If you have ever played around with the error_reported Extended Event, then it becomes very obvious that the SQL Server Error Log only logs a tiny fraction of the errors that are thrown by code ...
J. Mini's user avatar
  • 433
4 votes
1 answer
206 views

Granting SELECT...INTO permissions

I've created a new schema, archive, and am able to create, read, update and delete tables within it. I have an EXTERNAL_USER who I'm trying to give permissions to so that they can carry out select.....
philipnye's user avatar
  • 161
0 votes
0 answers
39 views

Role management in SQL Server

What is the best way to manage roles in sql server in Azure VMs (multiple). We want separate logins for each users but it should be same on all Azure SQL VMs. We are currently using windows ...
Bishal Basyal's user avatar
0 votes
0 answers
50 views

Does a system protected password automatically get included in SSMS when it is downloaded?

I work at a company where most things are password protected by a system admin password (which I dont have). Today I downloaded SQL Server and set up a basic local server. I was able to get in but ...
Matt Damberg's user avatar
0 votes
1 answer
42 views

Preferred seconday backup in AG - what about the primary ? Shows no backups taken

I did setup the Ola Scripts sticking to https://www.brentozar.com/archive/2015/06/how-to-configure-alwayson-ag-backups-with-ola-hallengrens-scripts/ Options are: @Databases = 'USER_DATABASES', @...
Thomas D's user avatar
0 votes
0 answers
20 views

Replication Error (SQL Server Management Studio 2019)

I am getting the following error in the Replication Monitor: "The replication agent had encountered an exception. Source: Replication Exception Type: Microsoft.SqlServer.Replication....
TenSecondTom's user avatar
1 vote
1 answer
42 views

Number of Real Months Between Two Dates

Background We have service contracts that can start and end on any arbitrary dates. Typically however, contracts end "X years minus a day". For example, typical date ranges: Start Date = ...
HardCode's user avatar
  • 288
0 votes
1 answer
25 views

SQL Pivot table splitting rows on custom column names. I need 1 row per OrderId

I have this PIVOT table below. I have to dynamically create column headings based on the itemid value (1 to 50) in each order. then horizontally list them. in this example, it works, but it splits ...
paygboy00's user avatar
1 vote
1 answer
105 views

Split intervals with two tables

I have two tables that allocate employees to cost centers. The first table (CCmain) shows the primary cost center. If an employee is assigned to more than one cost center, the second table (CCfraction)...
Stefan's user avatar
  • 13
9 votes
1 answer
662 views

Extra NESTED LOOP / INNER JOIN causing NO JOIN PREDICATE warning

I have the following tables in my database. LastNames Table CREATE TABLE [dbo].[LastNames]( [LastNameID] [int] IDENTITY(1,1) NOT NULL, [LastName] [varchar](50) NOT NULL ) ON [PRIMARY] GO ...
John K. N.'s user avatar
  • 17.9k
4 votes
2 answers
139 views

Index seeks and predicate push down

I have a query of the following form: IF EXISTS ( SELECT 1 FROM ( SELECT RowID, OETID FROM @InMemoryTableTypeTable i UNION ...
Dan Def's user avatar
  • 163
0 votes
1 answer
61 views

How to implement an "Apple or Orange but not both" constraint

A database schema design question: Suppose I want to design a database with Robots, Technicians and Sites. I want to use my database constraints to limit the data to prevent entering some nonsensical ...
rich p's user avatar
  • 233
0 votes
0 answers
38 views

Trouble Restoring DB/Logs to point in time

I am trying to use SSMS to restore a database to a specific point in time. When I select the point in time, I get 3 backup sets to restore, one of them with a null filename and location. The script is ...
Scott Bathauer's user avatar
0 votes
1 answer
52 views

Database systems - data type alignment padding and record size (C/C++ related)

In PostgreSQL there is alignment padding of various datatypes which can increase (or decrease) the size of records (as stored on disk) in varying ways (see these links, 1, 2, 3): I searched for "...
Vérace's user avatar
  • 30.1k
-2 votes
1 answer
50 views

Schema compare on production database [closed]

I often use Azure Data Studio's Schema Compare in lower environments like dev and uat, to get information about the schemas, before I commence with making changes and/or testing. I need to compare the ...
Divan's user avatar
  • 97
0 votes
1 answer
52 views

Speed up an already running insert script

I have an insert script running for about 10 + hours now, it's only inserting 8 million rows, but there are few index views built on that table. due the active insert transaction I cannot drop any ...
Marshal's user avatar

1
2 3 4 5
686