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
0answers
23 views

000 Unable to connect to server'(local)'; SQLServerAgent cannot start SQL 2008R2 WinServ 2012R2

The SQL Server Agent will not automatically start whenever the server restarts and has to be manually started I get the error from the SQL Log File Viewer along with these other errors. I know almost ...
1
vote
0answers
41 views

Is there any way to recklessly drop a principal leaving orphaned objects or should I assume only data corruption could cause it?

Given that SQL Server blocks me when I try to DROP a principal that owns an object in the database, if I see an object which the owner no longer exists, should I assume right away it was data ...
0
votes
3answers
51 views

I have SQL Server Management Studio 18 - Where I can find SQLServerManager / SQL Server Configuration Manager

I need to install SQL Server Configuration Manager in order to configure SQL Aliases, but I don't want to install whole SQL Server I expected it to be installed with SSMS, but I'm unable to find ...
0
votes
0answers
28 views

Combine multiple alerts in to single alert

I'm trying to find a way to generate a single alert by combining multiple alerts for AlwaysOn setup (for example error codes- 1480 , 19406) which gets logged in SQLERRORLOG file during planned or ...
1
vote
1answer
39 views

How to find the sql jobs that have not run for more than two months?

I would like to get a query to ascertain which sql jobs have not run for more than 60 days?
0
votes
1answer
23 views

After Insert Trigger WIth MS SQL Server

I think I have all my bases covered but wanted to ask someone who knows better than I. This is my syntax. UPDATE SI SET autoInsert = 0 FROM inserted WHERE SI.autoInsert = SI.autoInsert OR SI....
0
votes
1answer
28 views

Interpreting sp_BlitzCache: # Executions but since when?

I'm getting started with sp_BlitzCache (which is amazing!) and trying to understand the results better. When does the # Executions count from? e.g. if it says 343 executions is that today, since ...
0
votes
2answers
33 views

Is it possible to prevent SQL Agent Job from running if related job or previous instance has not finished?

I have three SQL Agent jobs, one for each of three registries being managed. These go off on a staggered schedule every two hours (i.e. Reg 1 at 9am, 3pm; Reg 2 at 11am, 5pm; Reg 3 at 1pm, 7pm). In ...
0
votes
0answers
22 views

Clarification on SQL Server database replication / Distribution / Performance

I started reading about the scaling database lately due to my recent engagement, and so far, I find it interesting and have been able to successfully set up transactional database replication with SQL ...
0
votes
0answers
26 views

Grouping by Results of a Select - Case

I am trying to select a value on one of two fields based on conditions so I am using Select & Case. I am also selecting the sum of sales and the customer name also using case. Here is my current ...
0
votes
0answers
16 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 ...
0
votes
2answers
43 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
votes
1answer
27 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 ...
1
vote
0answers
26 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 ...
-2
votes
1answer
46 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 ...
0
votes
0answers
30 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 ...
1
vote
1answer
51 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), ...
0
votes
1answer
46 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. (...
0
votes
1answer
23 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 ...
2
votes
1answer
42 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 ...
5
votes
2answers
233 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
50 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 ...
1
vote
2answers
56 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: +--------------------------------------+---------+--------------------------+----------------------...
1
vote
0answers
24 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 ...
3
votes
1answer
47 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 ...
3
votes
1answer
74 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 ...
2
votes
1answer
29 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 ...
0
votes
1answer
44 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
1answer
24 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 ...
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 ...
0
votes
0answers
25 views

How to customize mssql-cli to remove Time line from output and return green/red for message output?

When ever I execute any command using mssql-cli version 1.0.0 command prompt tool there are two lines displayed: Time: 0.252s Commands completed successfully. Questions: Is there a way to remove ...
0
votes
0answers
19 views

FileStream DB SQL Server - merging DB data

We recently upgraded a server from 2014 to 2017. Since down time was a concern, we migrated some DB's a couple days before. Migration complete Sunday afternoon, we've now come to find out the ...
-1
votes
1answer
62 views

How to practically run sys.dm_db_index_physical_stats against 460 THOUSAND tables?

I've been tasked with maintaining an old (SQL 2005; no, I can't upgrade it!) server which has 461,000 tables and 1.15M indexes. How do I go about analyzing all those indexes in bite-sized chunks? My ...
4
votes
1answer
266 views

SQL rolling back all iterations of a while loop when each iteration has its own explicit transaction

For the past few days I've been trying to write a query for an automated process that will delete records from a log table within a specified date range (a month) to another table, so they can then be ...
0
votes
0answers
66 views

SQL Server Snapshot replication - Failing to start the Publisher snapshot agent

I am trying to set up a Snapshot replication using an Azure SQL Managed Instance. While trying to see the Snapshot Agent status, I see this error. Failed to connect to Azure Storage '' with OS error: ...
0
votes
0answers
17 views

Sql Server Fulltext catalog gets truncated

We're facing an interesting issue which we can't reproduce. On our Sql 2012 from time to time our Fulltext catalog gets truncated, We read MSDN but we didn't find any information if there is such an ...
-5
votes
1answer
33 views

How can i remove the duplicate values while using inner join [closed]

I get duplicate AccountIDs if I use the below code. Select Distinct(BE.AccountID), SUM(BB.Balance) AS BonusBalance, [Freebet] = CASE WHEN be.Freebet = 1 THEN 'FREESPINS' ELSE 'BONUSDEPOSITED' END -...
0
votes
1answer
46 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 ...
-1
votes
1answer
42 views

Dynamic sql query with top count sqlserver [closed]

My Requirement I need to set\get a variable's value using the dynamic query I need to write a dynamic sql query to select top (@topCount) The @topCount will need to be a calculated value using the ...
2
votes
1answer
38 views

Merging a .bak to an existing SQL database

I have a SQL Server database with data from 1990-2018 in a .mdf file. I recently downloaded data for 2018-2020 and it's in a .bak file. When I went to "Restore" the database, it wiped out ...
0
votes
1answer
47 views

How to identify queries that cause high Logical I/O?

I need some help to identify SQL queries that could suddenly increase the SQL Server Logical I/O. Can someone please help to provide some advice? This was from SQL Server 2017
7
votes
1answer
109 views

FORMAT 'G17' vs 'G'

I have a question about this fiddle: DECLARE @TestVal AS float = 8.88; SELECT flt = @TestVal , xml = (SELECT Value = @TestVal FOR XML PATH(''), TYPE) , fmt17 = FORMAT(@TestVal, 'G17') , ...
4
votes
0answers
112 views

hash join hint returning error when using local variable

DECLARE @Id INT = 18471 SELECT c.UserId FROM dbo.Comments AS c INNER HASH JOIN dbo.Users AS u ON c.UserId = u.Id AND c.UserId = @Id The query above using Stackoverflow 2010 database with hash join ...
2
votes
1answer
65 views

Window Function - SUM() OVER (PARTITION BY … ORDER BY …)

i wish you all stay healthy and safe in this unprecedented circumstance. i am a newbie and asking my very first question in here. i have following dataset. green: original data. yellow: values that i ...
0
votes
0answers
55 views

Troubleshooting an automatic failover in 2 node multi subnet AG

I am trying to troubleshoot an automatic fail over that happened on our below infra- both of below running on HYPERV VMs Windows version 2019 SQL1 - 8 cores 64 GB RAM - No load running (Primary) ...
0
votes
2answers
19 views

Does “allow remote connections to this server” in sql server impact SSIS packages?

I'm wondering if anyone has experience with this setting "allow remote connections to this server" in sql server. I am partly responsible for a few hundred sql servers which run SSIS in ...
1
vote
2answers
37 views

SQL Server on azure virtual machines default instance

We have two ways of provisioning SQL Server on an Azure virtual machine, one is creating the VM and then upload the binaries of SQL server and do the installation manually, the second one is using SQL ...
0
votes
2answers
34 views

What is the difference between SET NOEXEC ON and SET PARSEONLY ON?

Currently, SQL server supports the following statements: SET NOEXEC and SET PARSEONLY. From the documentation: SET NOEXEC ON: When SET NOEXEC is ON, SQL Server compiles each batch of Transact-SQL ...
0
votes
1answer
15 views

Find Unique Index that does not have Unique Constraint

I need to find list of unique indices that does not have unique constraint on that column. How to achieve this? I know, following query will give me unique constraints. SELECT * FROM ...
0
votes
1answer
56 views

SQL server row count

I had an activity for restoring a full database in SQL server 2008. I had to restore the database will norecovery since I had to restore the differential backups as well which will be shared everyday. ...

1
3 4
5
6 7
571