Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 3847

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.

3 votes

FK on NON Primary Keys

Assuming you explicitly choose the clustered index for the table and have ensured the columns do not accept nulls (and I strongly suggest that you do both), there is no performance implications of a f …
onedaywhen's user avatar
  • 2,622
2 votes

Why did Microsoft kill "English Query" on SQL Server?

See this brief article: Microsoft hasn't said much as to why English Query was [discontinued]. One could speculate that it may be due to lack of interest or an inability to provide accurate tr …
onedaywhen's user avatar
  • 2,622
0 votes

overstating field size in database design

Field length checking is something you get 'for free', meaning you don't have to use a CHECK constraint to do the same. And you don't want oversized data values when, for example, you have to upload y …
onedaywhen's user avatar
  • 2,622
18 votes
3 answers
23k views

Meaning of 'SET' in error message 'Null value is eliminated by an aggregate or other SET ope...

I saw the above 'ANSI warning' message today when running a colleague's script (and I don't know which of the many statements caused the warning to be shown). In the past I've ignored it: I avoid nul …
onedaywhen's user avatar
  • 2,622
2 votes

Single Identity column and composite key, which to make primary?

It does not matter. Assuming you set attributes 'clustered' and 'not null' explicitly and independently (rather than using 'primary' to imply them) then 'primary' is merely a designation. The choice …
onedaywhen's user avatar
  • 2,622
3 votes

Perform UNION ALL regardless of column order in the two joined tables

In standard SQL (removing the INTO clause): SELECT * FROM Table2 UNION ALL CORRESPONDING SELECT * FROM Table3 Sadly, SQL Server has not yet implemented CORRESPONDING qualifier (same applies to INTE …
onedaywhen's user avatar
  • 2,622
3 votes
Accepted

Milliseconds to datetime

DATETIME is used to store an instant ("point in time") at a particular granularity (approx 300 milliseconds IIRC). The value you wish to store is an interval (or is it a duration?) in milliseconds. S …
onedaywhen's user avatar
  • 2,622
12 votes

Why aren't primary key / foreign key matches used for joins?

the concept of "joinability." Relations r1 and r2 are joinable if and only if attributes with the same name are of the same type... this concept applies not only to join as such but to various …
onedaywhen's user avatar
  • 2,622
3 votes

Comparing Columns that can contain NULLS - is there a more elegant way?

Standard SQL, supported in SQL Server 2005 and better: WITH A_MINUS_B AS ( SELECT * FROM A EXCEPT SELECT * FROM B ) SELECT * FROM A_MINUS_B AS T …
onedaywhen's user avatar
  • 2,622
1 vote

How do you ensure accuracy of your query

Take care with nulls and never forget that SQL's three-valued logic is treats constraints differently i.e. P(row) | WHERE P(row) | CHECK(P(row)) --------+--------------+------------------------- TR …
onedaywhen's user avatar
  • 2,622
12 votes

Does it make sense to use SQL Server's bracket notation in hand written code?

Standard SQL uses the double quote " for quoted identifiers. SQL Server supports this using the QUOTED_IDENTIFIER option (ANSI_QUOTES in mySQL). Standard SQL improves portability in general and in th …
onedaywhen's user avatar
  • 2,622
4 votes

6th normal form, recomposition query, efficient implementation

Download Dr. Hugh Darwen's free PDF book, An Introduction to Relational Database Theory. Specifically, chapter 7 and the WIFE_OF_HENRY_VIII example. In summary, 6NF is always achievable but may not al …
onedaywhen's user avatar
  • 2,622