Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql-server]

All versions of Microsoft SQL Server (not MySQL). Please also add a version-specific tag like sql-server-2016 if that is relevant to the question.

2
votes
1answer
23 views

How to run merge agent job step on tsql

I'm having a problem with the merge replication and I want to try and run the job as a script on ssms so I can see the errors (I've tried almost everything else) Original post Here is the script -...
0
votes
0answers
30 views

Execute of job failed. See the history log for details

I am learning SQL Server administration and setting up log shipping for the first time. SERVER1 is primary database and SERVER2 is secondary database. I was able to setup log shipping successfully ...
1
vote
1answer
42 views

Correcting and Detecting overlapped dates with CTE

I have a CTE that marks (as bits) overlapped records based on certain criteria. After filtering, I need to update these records to "correct" them and make them sequential, but I'm getting a 4104 on ...
1
vote
0answers
26 views

Repivoting rows of pivoted data with an dynamic amount of rows

I am trying to create an overall sequential pivot of various rows of data, repeating each row as a new set of columns and using the sequence number as the trailing identifier in each column name. Here ...
1
vote
1answer
32 views

Can I on purpose lock the admin out of an Azure SQLDB (as admin)

Can I on purpose lock the admin out of an Azure SQLDB (as admin) As this may sound as a strange question on first sight. The goal is to only have sql users with data reader & writer rights on the ...
0
votes
2answers
51 views

multiple ids table for accounting schema

I am trying to make a small accounting db and I have hit a dead end, my search bared no results as of how to make this idea work. In the picture below you can see that I am trying to link multiple ...
2
votes
0answers
71 views

2 SQL 2019 Servers with High Availability Linux with a shared Linux SQL Express 2019 Witness

Is it possible to have two SQL Always on High Availability servers in datacentre A replicating to two servers in datacentre B with one Witness using Express with two availability groups (one for each ...
1
vote
0answers
36 views

Giving Access to only one SQL Agent Job

I will only need to allow a user to execute a specific sql agent job rather than be able to execute the other jobs that are there . Please advice how to accomplish this
1
vote
1answer
29 views

What is the best type of account to use for SQL services? [duplicate]

We run stand alone instances all virtual. SQL 2012 - SQL 2017 Backups are performed by a third party tool so the server has no need to access anything on the network. Agent jobs are all run via proxy ...
2
votes
2answers
134 views

Cast as int in CASE expression in SQL

I have a query that is pulling data from 10 tables and a sub-query. One of the selects is for a location and I am using a case expression to clean up the data on output. The field it is pulling the ...
0
votes
0answers
26 views

Why am I suddenly getting type warnings on new database? [duplicate]

I restored a backup database from a 2008r2 server to a brand new instance of sql server 2017. When I run the same stored procedure, I am now getting type conversion warnings in the execution plan that ...
0
votes
1answer
29 views

Create employee rows for each date in date range

I have a list of employees. I need to create output which is one row per date in a date range for each employee. The date range will always be the last 15 days, so it is expected to have 15 rows for ...
2
votes
1answer
36 views

SSMS - How to Enable Word Wrap for Messages Pane

Sometimes I need to take screen shots of error messages in SQL Server. How can I turn on word wrap in the messages pane so I can capture all the text in the screen shot?
1
vote
0answers
14 views

Filtered Merge Statement [duplicate]

This is, probably, a really simple answer, but I am not coming up with it... Any help would be greatly appreciated: I created a web form, to a stored procedure, that submits userID, deptID, and a ...
0
votes
0answers
56 views

Easiest way to update XML inside of a SQL table column?

I have an SQL DB, Directory. It contains a table, dbo.User. Within that table there is a column, Info. The Info column contains ~1000 lines of xml tags. Well I want to modify only one of those tags, ...
4
votes
1answer
76 views

Is it better to have a wider single table or “child” tables based on business processes?

The example I am working with is an invoice data model, where there may be around 30 columns by the time we're done designing. Each row of data would be unique to a single invoice. Some of the ...
0
votes
1answer
56 views

Full Outer Join not working as expected [closed]

I want to make a view from these tables. The first inner join works as expected and brings a new column with AuspraegungID from which I want to connect to the ArtikelVarianten table At the moment I ...
0
votes
0answers
22 views

Set service startup using DSC

Windows PowerShell Desired State Configuration (DSC) newbie here. The MOF file generation fails with: PSDesiredStateConfiguration\Node : The argument is null or empty. Provide an argument that is not ...
-1
votes
2answers
87 views

Select distinct for one column and many in another column

I have: Name PhoneNo JOHN 555555 JOHN 555554 MIKE 111111 MIKE 122222 I want to display output like: Name PhoneNo JOHN 555555 555554 MIKE 111111 111112
2
votes
0answers
49 views

Troubles inserting new records in linked SQL-server table in Access

Years ago, I upsized the back-end database from Access to SQL-server using the build in tool in Access. It worked fine but in the recent two weeks an error began to appear. This problem occurs for ...
1
vote
0answers
11 views

Detecting disk throttling on Azure VM

Is it possible to monitor disk IO usage on an Azure VM or in SQL Management to detect whether disks are being throttled? How would you do it? Background: I'm looking for a way to raise an alert when ...
2
votes
1answer
84 views

Is it possible to step through TSQL that uses variables, in SSMS?

If I enter TSQL into SSMS Query editor, I know I can "step through" the statements (ie. execute them one at a time) by highlighting a statement and hitting F5 on the keyboard. It seems by default ...
1
vote
1answer
54 views

Number of rows summed up by grouping them, each group has a different number of rows

Every 4 rows need to be summed up and displayed against that group but every group has different number of rows, at the end of the group for the odd rows sum is different. For example, in the group ...
2
votes
0answers
35 views

Errors during CHECKDB

We have a db which reports errors when trying to do a backup: Starting to dig in, the first thing that was suggested was to run DBCC CHECKDB. I've been trying to run that all day now, and googling ...
-1
votes
1answer
28 views

How to Set the Transaction Isolation level in a Table Value Multi Function

How do I set the transaction isolation level within in a table value multi function? I know it can be done in a stored procedure. create function dbo.Test() RETURNS @TestTable Table (test varchar(...
1
vote
1answer
20 views

Debug Connection Pool Error

I have been getting the below error. System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: Timeout expired. The timeout ...
0
votes
0answers
32 views

Lost data after restore

I had an issue after backing up and restoring the DB's from server to server, We have since had some issues with missing information. Is there a way at this point in time to know if the databases ...
1
vote
1answer
45 views

Where to install or use SQL Server?

New to the database side of IT and I have a few questions... I'm trying to figure out what servers and databases I can access through SSMS. What is the best practice for installing/using SQL Server ...
2
votes
4answers
181 views

Include all possible values of sub-categories under each category

How can it be achieved in MS SQL 2016, when I need to always see every state under all existing categories even if there are no records, which satisfy the state formula? Under a and b below I always ...
4
votes
1answer
98 views

why is this left join faster than an inner join?

So I'm tuning this query, and I am pretty sure that in this instance, I can replace an inner join with a left join without affecting the data. However, I'm not entirely sure why this is faster. Here ...
1
vote
2answers
61 views

Exclusionary Left Joins

I'm trying to join 2 different tables (Table99 and Table2) to Table1. The first is a straight-forward RIGHT JOIN. The second is a LEFT JOIN, where I'm trying to take Table1 and Left Join to a Table2,...
-1
votes
1answer
59 views

LEFT OUTER JOIN fails to find matching row

This one has me about beat. The following is code within a stored procedure that, if run repeatedly, continues to 1) fail to identify a matching row and 2)insert a new identical row. The values and ...
2
votes
1answer
81 views

Should I use the deprecated MD5 function in SQL Server?

We'd like to use MD5 for our hashing function instead of SHA_256 but as of SQL Server 2016, MD5 is deprecated. We're using this for hashing (comparing which records have changed). We now have this ...
1
vote
3answers
270 views

SQL Server statement takes forever while running instantly in Oracle

Please help me interpreting this statement and plan: https://www.brentozar.com/pastetheplan/?id=Bysy6YtEV We migrated from Oracle to SQL Server and we have some quite strange behaviours. It might be ...
2
votes
1answer
76 views

Storage and presentation of data across multiple languages

Apologies if this has been asked before. After extensive searching I cannot find anything that serves as a solution (a similar answer is posted below). I am afraid this is an open-ended (broad) ...
-2
votes
0answers
26 views

Comparing two tables in different server instances [closed]

We have two systems, one is a legacy server (SQL Server 2014) and other one is cloud-based Azure DB (SQL Server 2017). We have the same tables in Azure as in the legacy system. How can we check if ...
5
votes
1answer
79 views

Columnstore index for Key/Value Pair table on SQL Server

I need to build a database for storing assessments. Each assessment can have an indefinite number of questions, and an indefinite number of responses. Responses for each assessment can grow up to ...
2
votes
0answers
16 views

How to get more details about root cause of failed Database Mail SSL connection

I'm trying to send database mail over SSL/TLS-encrypted SMTP. It works when sending plain text email, but fails when I enable SSL/TLS. The database mail log shows the following error message: Date ...
4
votes
2answers
52 views

Byte ordering for multibyte characters in SQL Server versus Oracle

I am currently in the process of migrating data from Oracle to SQL Server and I'm encountering an issue trying to validate the data post-migration. Environment Details: Oracle 12 - AL32UTF8 ...
3
votes
0answers
44 views

Should I use Transactional Replication here?

I have a database on SQL Server A & one on SQL Server B. (SQL 2017 w/ enterprise) They share similar objects and need to be kept fairly up to date. Both will require changes to be passed to each ...
2
votes
1answer
41 views

SQL Query Store qds_async_queue

I've recently inherited a SQL Server 2017 instance with performance issues and I've been able to remediate the low hanging fruit. However, one substantial wait still remains. The Query Store - ...
0
votes
1answer
26 views

SQL Agent Job dependency

I have a requirement is SQL Agent Jobs where their is a job called Job 4 which dependent on 3 other jobs say Job 1, Job 2 and Job 3. So this Job 4 has to be triggered whenever either one of the 3 jobs ...
1
vote
1answer
37 views

SQL Server Redirect

I have looked at many of the post for this but don't find something quite like what I need. This may sound like a weird request but: We have a partner with a SQL server on their network and we need to ...
2
votes
0answers
31 views

SQL Server stored procedure not throwing certain kind of error

I noticed an issue in my app recently where an database insert that occurred in a stored procedure was failing, but no exception was getting thrown. The insert failed because a column that doesn't ...
1
vote
1answer
36 views

Datetime hourly precision

What would be the best to store date + hour + timezone in SQL? i dont need a higher precision (minutes, seconds, ms..) the primary reason for this is to reduce memory use and calculation time on big ...
0
votes
3answers
71 views

Change sql server service account without restarting SQL Server

for security reasons we want to change the password that starts the sql server service everyday,is it possible to do this without restarting the service? if it is possible will the changes be ...
1
vote
1answer
46 views

Efficient method to update character length of columns in large table

I have a table with 80+ million records. There are 2 columns which are currently varchar(MAX), which I would like to update to varchar(255) to save space. It is not an issue if data will be truncated. ...
3
votes
2answers
292 views

Cross join yields execution plan that reads one of the tables multiple times

I have a query where I need to cross join a small table with 5 rows to a table with roughly 31k rows. The execution plan SQL Server came up with does index scans in both tables and joins them with ...
0
votes
1answer
17 views

MS SQL -Date and Time Style conversion problem

I need to convert Date and Time Style from USA format to German and than cast that into int data type. So for variable in case below this works fine if I want to display it in Standard 112 (ISO) ...
0
votes
2answers
53 views

Is a millions-row query fetched in the SQL Studio client slower than other applications?

I'm not sure if want I'm thinking makes sense. I have a SQL Server database table with 30 million rows. If I do a select A, B, C, D from huge_table --- (about 30 million--- total 4 GB footprint) --- ...