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,668
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
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

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
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
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
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
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
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

Only top scored, non community-wiki answers of a minimum length are eligible