New answers tagged

3 votes
Accepted

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

This is an 'islands' problem. One popular and efficient solution is to number rows in the desired order. When there is a gap in the sequence, the difference between the ordering column and the row ...
user avatar
  • 70.9k
2 votes
Accepted

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

According to docs.microsoft.com you should not delete the Update Cache folder. As for the Log folder I'd say that you can delete it as long as you do not need the logs stored there.
user avatar
  • 173
0 votes

Disk Response time high on Tempdb

After spending many days and involving other teams (VM,Windows and Storage),we noticed in the VM Center that the Disk Consolidation pending on the VM( db server). after performing the Disk ...
user avatar
5 votes
Accepted

Case sensitivity not working

[A-Z] is a range of characters. The characters in the range depend on the sort order defined by the collation: SELECT SV.number, CHAR(SV.number) FROM master.dbo.spt_values AS SV WHERE ...
user avatar
  • 70.9k
0 votes

Tsql help - doing a large update from CSV file to a table in ssms

there's an easier way to import csv files with a very neat formatting, you'll do it on 2 steps: 1- run the following query on the file to check number of columns and their names: select top 1 x.* ...
user avatar
1 vote

How to generate ER diagram for specific tables in MSDB

When you create a database diagram connecting fields between various tables you are creating constraints i.e. foreign keys. You should create new FKs only on databases you know well, not for system ...
user avatar
  • 3,462
5 votes
Accepted

How does SQL estimate the number of rows in a less than < Predicate

for this query, SQL Server estimates 109,579 rows but I can't work out where it has got that from: RANGE_HI_KEY + RANGE_ROWS of all buckets up to and including RANGE_HI_KEY 470 = 109,566 so we are 11 ...
user avatar
  • 70.9k
3 votes
Accepted

No column name was specified for column 1 of 'd'

You don't need to join to tblTemp again in your sub-query. You can use APPLY operator to make your query more readable. SELECT tp.id as tmpltID, STUFF ( pd.Name, 1, 2, '' ) as colNames FROM [...
user avatar
  • 518
0 votes

AlwaysOn Availability Group creation - Is it possible to delay the adding of a secondary replica?

Yes it is possible but you need to use T-SQL. It is not possible using wizard in ssms. Here is the link how to configure new AG using T-SQL just skip everything related to secondary replica. https://...
user avatar
  • 164
1 vote

How to get numbers that have IE in case of data type float?

First expected output: SELECT Numbers FROM #TestTable WHERE Numbers < 1e0; Second expected output: SELECT FORMAT(Numbers, '0.########') FROM #TestTable; Note this returns nvarchar using a custom ...
user avatar
  • 70.9k
1 vote

How to get numbers that have IE in case of data type float?

You can't do that in the query, since the formatting of data is done by the client application. Or, to be more specific, you would need to tailor the query to your particular client application and ...
user avatar
0 votes

AlwaysOn Availability Group creation - Is it possible to delay the adding of a secondary replica?

Unfortunately not. You have to specify at least one secondary.
user avatar
0 votes

SQL Server 2016 - TDSSNIClient initialization failed with error 0xffffffff, status code 0x80

Had the same error. Changing service user account or messing with certs, disabling TLS, etc. all had no effect. Turns out the server could no longer see the Domain Controller/Active Directory (...
user avatar
  • 135
1 vote

MS SQL Server 2016 SP3 upgrade failing

After trying several things, finally this worked for me: I renamed the existing C:\Temp folder to C:\Temp_old and created a new Temp folder in the C drive.
user avatar
7 votes
Accepted

Trigger execution order after delete

From the docs: An AFTER trigger is run only after the triggering SQL statement has run successfully. This successful execution includes all referential cascade actions and constraint checks ...
user avatar
  • 5,643
3 votes
Accepted

Why Does SQL Server not have 200 buckets in the statistics histogram when there are >100k distinct values in the table

The histogram in this case is nearly indistinguishable from prior to inserting the 4 duplicate values. At that time, the unique and sequential series could be completely described by three steps. The ...
user avatar
  • 1,343

Top 50 recent answers are included