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
1answer
80 views

Query distinct emails not logged in within a period of time

I need help in writing a query to return distinct emails that have not logged into ABC database in the past 5 months. The exact task I have been asked is as following: Create a table in ABC ...
0
votes
0answers
6 views

LIQUIBASE Locking our DB with duplicate IDs post migration - handling changesets

I apologize in advance if this is the wrong thread category but we recently migrated a DB and our liquibase configuration is seemingly not recognizing that there is a new path so Liquibase seems to be ...
-2
votes
1answer
40 views

Multiple condition case when query

Edit: I figured out the code. I decided to go a totaly different way with it. IF the software is comptible I make the background green, if not compatible I made the background red. Here is a sample ...
3
votes
1answer
201 views

Why can't I persist binary(4) computed column?

I'm playing with storing and indexing IP addresses. I'm starting with a simple, stupid table: CREATE TABLE [dbo].[IP_addresses]( [IP_as_text] [char](16) NOT NULL, [IP] AS ([dbo].[...
0
votes
1answer
24 views

How Are SQL Server Clients Connecting?

I am asking two questions in this post. If I see activity in netstat with port 1433 for an unnamed instance, whose tcp addresses are not enabled, what does that mean? What is the preferred way to ...
1
vote
0answers
16 views

Export and split QUERY results in multiple files

I would like to know if it's possible to export and split query results in multiple files. Let's assume I have a query returning 100 results and I want to save the results in 5 different csv files (20 ...
-1
votes
1answer
16 views

Running total for current period when previous period is empty

I could use a little SQL help this morning I am new to SQL and could use some help. I have a stored proc set up in SSMS whose purpose is to determine the quarter to date total of transactions for a ...
0
votes
1answer
15 views

How to use BCP Utility queryout in a network path with crededential (login required) for SQL Server

I'm having a hard time figuring out on how can I export my selected table in a network path that requires login credentials. 'bcp "select ''StudentName'' UNION ALL SELECT StudentName AS ...
1
vote
2answers
1k views

Is there anyway to change the standard SQL SERVER reports? And/OR See the SQL Behind it?

SQL SERVER (through Management Studio) offers quite a few standard reports, but I don't see how you could change the reports. I don't even see an option for extracting/obtaining the SQL Code behind it....
0
votes
1answer
196 views

What exactly happens during Database Mirroring? What about during a fail over?

So I am trying to configure a two server setup, both containing SQL with independent storage. We're using windows server 2012, and I have a question about mirroring. If the server's data bases are in ...
0
votes
2answers
34 views

SQL Server sharing drive location

DBA newbie here. Did some searching online but cannot find a definite answer on this. Is it acceptable to share the drive where .MDF files reside with other non-SQL Server files such as applications ...
0
votes
1answer
43 views

SQL Server Agent unable to view network drives

I am unable to get agent jobs to output to a network path. I have pushed the IT guy to set up a domain authenticated user that logs in when the agent starts. That login does have access to the domain ...
1
vote
0answers
14 views

What would cause an elastic pool to exhibit high “Sql Server process core percent” metricsj, but low DTU / CPU

Backstory: We have an azure sql elastic pool with several databases in it and around 750GB of data. We've been having some sporadic outages which correlate with the metric "Sql Server process ...
0
votes
1answer
2k views

SQL Server updates missing from WSUS

I don't use WSUS for SQL Server patching because we have so many different compatibility issues, requirements and downtime OLA's that it makes it impossible to deploy anything in this way - not sure ...
0
votes
0answers
27 views

Missing tables in AdevntureWorksDB

Recently I found some old questions that involve querying data from AdevntureWorksDB across several operations(DML,DDL). One such question was : Create and execute a query that computes the total ...
0
votes
1answer
90 views

Login failed for user 'NT Service\SSISScaleOutMaster140'

In times of creating replication by using below query I getting from log Login failed for user 'NT Service\SSISScaleOutMaster140' DECLARE @distributor AS sysname; DECLARE @distributionDB AS sysname; ...
4
votes
1answer
206 views

SQL Server on linux unable to export to bacpac [closed]

I'm trying to export my database to a .bacpac file. I get the following error: (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) The command I'm using is: /...
3
votes
1answer
38 views

SSMS / SQL-Server delays console output (RAISEERROR WITH NOWAIT)

It is well known, that SSMS (or maybe the SQL Server, but I'd guess more the SSMS) delays PRINT messages until several lines (40) are gathered in the buffer, before they are really printed to the ...
2
votes
1answer
67 views

Constraint violation in a trusted constraint

I have a table with a constraint on it that has an existing record that is in violation of that constraint. While this is possible if someone applied the constraint without a check and after ...
1
vote
1answer
37 views

SQL Server - Why am I getting TCP connections without sessions?

I enabled SSL with Forced Encryption enabled, using a self-signed certificate. Then I've set up automated monitoring to detect not secured connections (seems redundant, I know, but bear with me here), ...
1
vote
1answer
20 views

fulltext_stoplists to database_principals issue

When I run a DBCC check against the database, it informs me that there is an issue with the sys.fulltext_stoplists object. It appears that the principal_id in stoplists does not have a relationship ...
0
votes
2answers
130 views

Why is my SQL Server database file so large?

I have a relatively simple database that is over 300MB on disk. When I look at the table data it adds up to just over 5MB. Please see the screenshot below: This screenshot can also be seen here. ...
1
vote
1answer
83 views

SQL Server High Disk Queue, Low CPU

I'm running a large-ish SQL Server Enterprise 2016 Data Warehouse where we've for some time now had issues where we are seeing the following symptoms: High Disk Queue length, including 100% activity ...
19
votes
2answers
3k views

Truncate a table with 17 billion rows in an AG

I need to truncate a table with 17 billion rows, the table is in a database that is part of an AG. What will be the effect of this operation on the AG latency and the size of log backups? Is there a ...
1
vote
1answer
163 views

Some queries not logging using RDS's SQL Server with C2 Auditing enabled

Similar to a past issue I had with audited queries not showing when using Extended Events, I'm having an issue with queries not logging when using C2 Auditing on an RDS SQL Server instance. (I would ...
1
vote
2answers
540 views

Unique key constraint violation not escalated to parent stored procedure

I have a stored procedure which calls 2 nested sub procedures. For Example, MyProc BEGIN BEGIN TRY BEGIN TRAN EXEC UpdateProc EXEC InsertProc COMMIT TRAN END TRY ...
2
votes
1answer
84 views

How to cope with SQL Server 2012 vs SQL (Azure) Database sql files

I'm trying to port my system to SQL Database (Azure instance) from SQL Server 2012. I'm using Visual Studio 2013 and I have my .sqlproj with all the definition of my database inside. Given that a ...
1
vote
2answers
10k views

Connection problem different errors .net application

We have a SQL Server with some relational databases. We have another webserver with applications which communicate with the databases. We have an issue with one of our customers. We get some errors ...
3
votes
4answers
66k views

SQL Server How to Set up Maintenance plan to shrink log

So I have a log file which grows very large after I run an SSIS job daily, sometimes up to 1220MB. In my database options I have set my recovery model to "FULL". When it is to FULL and I perfrom ...
0
votes
1answer
137 views

How to Calculate Month over Month User Retention based on already active users (not based on user signup date)?

I have a Table which tracks User activity (i-e user started a session at what time ?). This table contains the data from Dec 2018 Till now. I need to calculate monthly retention (not based on signup ...
0
votes
1answer
34 views

Why am I getting an email size error with SQL Server database mail? [closed]

I am sending 6 .csv files as attachments through SQL Server Email. But Email is failing with the following message in the database mail log: Exception Message: Cannot send mails to mail server. (...
1
vote
1answer
194 views

SQL server Installation

I have received a new server. The server has the following specification. It has 500 gig 7.2K RPM disk, SSD NVME 1.2 TB 10K RPM disk. All are in RAID 1. I am planning to install Windows Sever on ...
20
votes
2answers
3k views

How do you enable SQL Server 2019's result set caching?

SQL Server 2019 CTP 2.3 added a few new columns to sys.databases, including is_result_set_caching_on: It's not documented yet in the What's New in SQL Server 2019, nor in the ALTER DATABASE page. I ...
0
votes
1answer
93 views

Create a table with the same constraints,triggers,indexes, and statistics for house-keeping table

I have a current database with few hundred tables, say, tables A,B,C... and I want to create the same tables with the same constraints,triggers,indexes, and stats as the original tables. I know I ...
1
vote
2answers
48 views

select rows on distinct column value without vendor-specific sql syntax

I'm trying to select distinct rows without any vendor specific syntax. My table layout is as follows: +--------------------------------------+---------+--------------------------+----------------------...
0
votes
1answer
589 views

SQL server - data successfully inserted in a table but not returned in Select Statement

SQL select query not returning records, even though the data insert operation is successful. We have a table [dbo].[Login] in our database where data is inserted using the below stored procedure. The ...
0
votes
0answers
27 views

Age Field, Get the Ages and Count by Age [closed]

I found this SQL and was trying to modify to fit my needs. It works well, but, I would like for the code to get the "[Person_Age]" then count, where the Case Statement is not needed for all ...
0
votes
1answer
44 views

Setting Up Named SQL Server Instance Network Connection

I have successfully installed a second and named instance of MS SQL Server (14) on a Windows Server 16 system. The first instance is the default instance, and it was set up with the correct IP address ...
2
votes
0answers
67 views

SQL Server Polybase Data Movement Service stopping after few seconds

I have been scratching my head for a while now on how to fix this issue, SQL Server Polybase Data Movement Service starts successfully however after a few seconds it just stops. The OS on our server ...
25
votes
4answers
61k views

What is the use of “Backup set will Expire:” option while creating Backup Database task in Maintenance plan

While backing up the database, I would like to use "Backup set will Expire:" option to delete/overwrite old database backups. I am not able to use this option. Any advice on how to use "Backup set ...
2
votes
1answer
42 views

What could cause a sleeping session to have an open transaction?

For one of our SQL servers there has been a proc which creates a blocking mess: That stored proc completes under a sec most of the times but somehow is leaving transaction open. What i see from ...
0
votes
1answer
86 views

SSIS: Import Excel file to SQL Server

Is there a Excel version for this article? I have been searching for this past days but there is no luck. https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/
2
votes
1answer
26 views

Is it possible to expose the max depth of the B-Tree behind a rowstore index or a way to see how many nodes were traversed for a particular query?

I'm personally interested in data structures and with knowing that rowstore indexes are stored with a B-Tree behind them, I'm always curious in trying to visualize what those B-Trees look like for a ...
6
votes
2answers
32k views

SQL Server: Frequent Login timeout expired in Linked server

I am using SQL Server 2012. I have scheduled a job to run every 1 hour, with 1 step calling 1 simple Stored Procedure. The Stored Procedure migrates around 1K data from production server to our local ...
-3
votes
0answers
11 views

Install SQL Server 2017 - CU21 on Distributed availibility group (DAG) environment [closed]

I have to install SQL Server 2017 - CU21 on Distributed availibility group (DAG) environment. Could you please share the steps to install CU21 on all 4 DB servers. DC1: SQLDB1 (Primary) SQLDB2 (...
5
votes
3answers
798 views

Deleting data from a table containing LOBs did not reduce the amount of data reported INTERNALLY by the table or database

Running SQL Server 2012 standard, using both replication data and log shipping. Transaction log backups are created every few minutes. This question is NOT about the amount of space reported by the ...
1
vote
1answer
23 views

I am looking for a query to determine when the snapshot has been finished applying on the subscriber

Is there any way to determine with a query when the replication has finished applying the snapshot on the subscriber? I have a transnational pull replication set up for reporting purposes and it also ...
0
votes
1answer
43 views

Comparing running total with group by

working with Two scenarios CREATE TABLE [dbo].[Test]( [LineID] [int] NULL, [BusinessUnit] [nvarchar](50) NULL, [Value] [nvarchar](50) NULL, [Amount] [money] NULL ) ON [PRIMARY] GO ...
32
votes
3answers
31k views

For absolute performance, is SUM faster or COUNT?

This relates to counting the number of records that match a certain condition, e.g. invoice amount > $100. I tend to prefer COUNT(CASE WHEN invoice_amount > 100 THEN 1 END) However, this is ...
0
votes
2answers
95 views

select query with where clause having variable taking more time to execute [closed]

I have a query which selects a couple of rows from a view based on the variables declared. I ran the same query in lower environments and to my surprise, I got the result in less than 3 minutes ...

1
2 3 4 5
567