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
-2 votes
4 answers
38 views

Automate sql reports and send them by mail

Hellos I work in large retail business with a decent sql server environment. Sql replication, availability group, data wear house, and some cloud services. We this beautiful environment we use a ...
user avatar
  • 37
2 votes
2 answers
184 views

Is a clustered index of 3 columns too big?

My goal is to design a table, that can be queried trough an external id(uniqueidentifier), an internal id(bigint), always in combination with companyId(bigint), userId(bigint) and dashboardId(bigint) ...
user avatar
  • 33
-2 votes
1 answer
26 views

How sum over work

Given this table: CREATE TABLE Table1 ( [Classroom] int, [CourseName] varchar(8), [Lesson] varchar(9), [StartTime] char(4), [EndTime] char(4) ); then: INSERT INTO Table1 ( [Classroom], ...
user avatar
  • 99
0 votes
1 answer
50 views

Query to find the count of active days (days with status = ON) between specified dates

I have a table as you can see below : create table z_test_duration ( Days date, Status char(8) ); Sample data is as below : Days Status 1/1/2022 on 1/2/2022 on 1/3/2022 on 1/4/2022 off ...
user avatar
  • 1,302
-4 votes
0 answers
39 views

SQL FOR Calculate Month & Year Wise Closing

I have Following table: MONTHS YearS ItemGroupMasterId OPUnitQuantity TrnIwUnitQuantity TrnOWUnitQuantity closing 4 2021 30 27534.3 83792.1 102161.36 9165.04 5 2021 30 0 56806.49 52938.08 0 6 2021 ...
user avatar
  • 1
0 votes
0 answers
16 views

Has anyone implemented TDE on two node AlwaysOn Cluster with Replication?

Looking for instructions to implement TDE on AlwaysOn with Replication. Current set up is Failover Cluster with Replication. Any gotchas to add TDE and AlwaysOn combination with Replication?
user avatar
  • 327
5 votes
2 answers
257 views

Records greater than epoch timestamp using only LIKE operator

I have the following query so far and unfortunately, I cannot use regexp or greater than operators, I can only use the LIKE keyword. The whole column is in a json string, I can't use json_value or ...
user avatar
0 votes
0 answers
36 views

Indexing operations on a 8TB AX dynamics database

We have an 8TB AX dynamics database on SQL Server 2016 Enterprise Edition. Our team would like to perform indexing operations but for a max of 8 hours with minimal impact during the week. My ...
user avatar
  • 11
2 votes
1 answer
104 views

Can I delete these SQL Server files to clear up disk space?

We're looking for opportunities to clear up some disk space on a Windows 2019 server. We're running SQL Server on this instance as well. I see that I may be able to free up 10GB if we clean out the ...
user avatar
  • 123
-1 votes
1 answer
60 views

SQL Server - Find Memory ALLOCATED vs. Memory ACTUALLY USED

I want to find average Memory USED per day. SQL server caches as much data as possible in RAM (Buffer Cache) - this is ALLOCATED RAM But how much of this data does it actually read subsequently - this ...
user avatar
  • 1,076
0 votes
0 answers
61 views

Sys.dm_os_performance_counters DMV row counts

We have noticed an odd issue on two servers in a 3 node SQL Server 2017 cluster running Always On Availability Groups. When checking the DMV sys.dm_os_performance_counters the row counts are totally ...
user avatar
  • 405
-1 votes
0 answers
38 views

SQL Query question: view to summarize by date also if no data

I am trying to summarize data entries by administrative level, let's say districts (in total 30) and day. Now every day data is collected in each district but we are summarizing in real time so at the ...
user avatar
  • 1
0 votes
2 answers
47 views

Fully qualified or synonym for table in another database, cloud migration plan

Scenario: In SQL Server on-prem and plan to go the cloud in a year or two. I am writing a stored procedure in database A and I need to access a table from database B. Is it a best practice to create a ...
user avatar
  • 9
3 votes
1 answer
60 views

Curbing Wasteful Memory Grants - MSSQL 2017

I'm running an on-premise SQL Server 2017 Enterprise at the latest patch/CU level supporting vendor software, which will become important later on. Server Stats: Virtual Machine (Memory is Pinned) ...
user avatar
1 vote
1 answer
24 views

How to Restore to AWS RDS SQL Server from TDE Enabled SQL DB(on-premises) backup file stored in S3

I have a on-premises TDE enabled SQL DB backup file available in S3 along with Cert and Pvt Key files. How to restore in AWS RDS SQL DB by utilizing the same master key password provided during source ...
user avatar
0 votes
1 answer
43 views

Script server level user securables onto another server

I have restored a backup of the live DB on a test SQL Server VM. Then I scripted the server level SQL users and restored them on the test SQL Server and fixed the orphaned user situation. But the user ...
user avatar
  • 2,375
0 votes
1 answer
29 views

Optimal procedure for partitioning with auto-increment PK as boundary value

I'm working with an application that deals mainly with large sets of related cost and planning data. This data gets stored across maybe 20 different tables in various models. Each set of data is ...
user avatar
-1 votes
0 answers
51 views

Large Cartesian Product

I just spoke with someone at straightpaths.com who suggested I try this forum. I'm creating a "paths to victory" solution for a series of games where each game has 8 players who will finish ...
user avatar
4 votes
1 answer
199 views

How to decrypt the name of columns from view?

I had to deal with a third-party database, I am trying to get all columns used in a view but I got them encrypted e.g: instead of getting int for NUMERO_SALARIE I got TNumSal why? DECLARE @...
user avatar
0 votes
2 answers
74 views

I can't create a Database after I uninstalled SQL Server and then reinstalled SQL Server

I uninstalled SQL Server and then reinstalled SQL Server on my laptop and now when I try to create an old database from my first installation called 'SSIS' and I get the following error: Msg 5170, ...
user avatar
0 votes
1 answer
47 views

Clustered Index Maintenance

I am running SQL Server 2012 and I am wondering if I create a clustered index if, as time goes on and users add records, if the RDBMS will maintain the clustered index on table change or have to do ...
user avatar
0 votes
1 answer
46 views

Case sensitivity not working

I have an issue where I keep getting the value 'CtP_PETER_Fact' out of the query below. It should be a case sensitive where-clause. I tried it in a few different ways: setting the COLLATE statement ...
user avatar
-2 votes
0 answers
45 views

Why is a stored procedure, renamed using sp_rename, not shown in SSMS? [closed]

I renamed a stored procedure using sp_rename system stored procedure but now I am unable to find it in the database in the SSMS browser. I have refreshed the IntelliSense Cache also, and restart the ...
user avatar
2 votes
1 answer
96 views

tSQLt test problem for some DDL queries

I am a SQL Server DBA. To automate some of my daily tasks, I need to write stored procedures. Creating functionality without testing does not make sense to me. For creating and running my tests, I ...
user avatar
-2 votes
0 answers
34 views

SQL Transaction log file 900+ GB Microsoft sql server manager [duplicate]

I have software installed on our server's secondary drive with capacity 1.04TB. Unfortunately the sql log file has consumed almost 900GB and I tried many option to shrink it, but every time it ...
user avatar
1 vote
1 answer
103 views

Find and show special character codes from nvarchar column

I want to know which special characters (line breaks, tabs, etc) are in my column of type nvarchar. I know how I can select which rows contain a specific character. e.g. SELECT * FROM your_table WHERE ...
user avatar
  • 229
-3 votes
0 answers
18 views

how to update master table counts in tracker table [closed]

Master tables list : TableA,TableB,TableC Main table : Trackertable Tracker table having columns CountUpdatedDate,TableA,TableB,TableC i want each and every time with date master tables counts are ...
user avatar
2 votes
0 answers
51 views

Service Broker performance issues after upgrading from 2012 to 2017 - tons of LCK_M_IX

Last night we upgraded a SQL Server 2012 server to SQL Server 2017 + CU 29. This is one of a matched set - we send the same message to both and each processes it. No, this is not AlwaysOn; we're ...
user avatar
  • 433
0 votes
1 answer
46 views

REPLACE() function accepts and returns non-character data types

The Microsoft documentation indicates that the REPLACE() function accepts and returns only character data types. However, these work without error: SELECT REPLACE(123456, 'X', 'Y') ; SELECT ...
user avatar
0 votes
0 answers
31 views

SQL Server cannot browse to any path

I have a local SQL installed on drive C: and the data file of those system databases are stored on a network drive path, in this case it is AWS FSx. When I attempt to restore a user database, I cannot ...
user avatar
  • 200
0 votes
2 answers
37 views

Help With Creating a Trigger

I'm having a lot of doubts about creating a Trigger After Insert that after entering a new flight checks if it is the first flight of the assigned plane. CAn you Please Help Me
user avatar
0 votes
1 answer
24 views

schema ownership/permissions in MS-SQL vs Oracle

Hopefully I'm using the write terms here. I'm pretty good with concepts usually but don't always know the technical terms to describe it correctly. Here goes... I'm used to working in MS SQL Server ...
user avatar
  • 173
0 votes
0 answers
50 views

Unable to attach other 2nd MDF file Error It is not a primary Database

The windows got crashed and we copied the file from hdd to other machine..... Let me explain you .. We have this db since many years one day the c:drive got full so the dba make changes and create new ...
user avatar
0 votes
1 answer
14 views

PolyBase :: Changed database context to 'DWQueue'

I'm installing PolyBase on the latest SQL Server 2019. During the installation I'm incurring in this error: https://www.youtube.com/watch?v=Oxd8yeiBfig (sorry for the video quality) The proposed new ...
user avatar
1 vote
0 answers
43 views

SQL server job agent fails to execute SSIS package, the package runs fine manually

I have a job which executes two packages. Step 1 is a package which is no longer executing under the job agent although it was executing fine before the server reboot. The package executes fine ...
user avatar
-3 votes
0 answers
28 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
35 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
67 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
27 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
24 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
59 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
165 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
43 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
69 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

1
2 3 4 5
639