What is the difference between a candidate key and a primary key? A table can have many candidate keys, but only one of them becomes the primary key.
SQL SERVER – Find Hostname and Current Logged In User Name
Connected to many servers in SSMS? HOST_NAME() and SUSER_NAME() show the hostname and current logged in user for any query window.
SQL SERVER – Leading Zero to Number
Readers keep asking how to add a leading zero to a number. Here are my two earlier articles that pad a number with zeros for a fixed width display.
SQL SERVER – Find All Servers From Local Network – Using sqlcmd – Detect Installed SQL Server on Network
Find every SQL Server on network with one command: sqlcmd -L or osql -L lists the instances on your local network. An update to my old isql script.
SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display
SQL SERVER – UDF – Pad Ride Side of Number with 0 – Fixed Width Number Display. Let us learn more about this blog.
SQL SERVER – Pad Right Side of Number with 0 – Fixed Width Number Display
A reader needed a fixed width number display, like 1 shown as 0000001. SQL Server has no ready-made function, but a simple string trick does it.
SQL SERVER – Generate A Single Random Number for Range of Rows of Any Table – Very interesting Question from Reader
A reader asked how to get a single random number for a set of rows, like one per PostalCode. I compare NEWID() for each row with RAND() for a whole set.






