Some SQL Server Programming Hacks
NULLS
- Testing for NULL values
- Use COALESCE To Return First Non Null Value
How To Check If Any, ALL Or No Parameters Have A NULL Value - Return first non null value
- Return Null If A Value Is A Certain Value
- Concatenation with nulls
- NOT IN and nulls
Dates
Sorting, Limiting,Ranking, Transposing and Pivoting
Handy tricks
- Five ways to return all rows from one table which are not in another table
- Order IP Addresses
- Data formatting dates
- Data formatting SSN
- 6 Different Ways To Get The Current Identity Value
- Use XACT_ABORT to roll back non trapable error transactions
- Random Sorting
- Sort Values Ascending But NULLS Last
- Adding Leading Zeros To Integer Values
- How do I format money/decimal data with commas?
- Find Out How Many Occurrences Of A Substring Are In A String
- Ten SQL Server Functions That You Have Ignored Until Now
- Use the *1 trick to do math with two varchar values
- Store The Output Of A Stored Procedure In A Table Without Creating A Table
- Find all The Rows Where Any Of The Columns Is Null Or Zero Or Both
- Three Ways To Display Two Counts From a Table Side By Side
- Finding duplicates across columns
- Use REPLACE To eliminate unwanted characters
Pitfalls
- Update triggers
- Integer math
- Identity Values And Triggers
- Use XACT_STATE() To Check For Doomed Transactions
- Three differences between COALESCE and ISNULL
- Non deterministic functions and nullif
- Subquery typo with using in
- ISNUMERIC Trouble
- Case Without Else
Query Optimization
- Case sensitive search
- Functions on left side of the operator
- Query Optimizations With Dates
- Optimization: Set Nocount On
- Don’t use arithmetic operators on a column in the where clause
- Don’t use * but list the columns
Undocumented but handy
- xp_getnetname
- xp_fileexist
- xp_dirtree
- xp_subdirs
- xp_getfiledetails
- xp_fixeddrives
- Sp_tempdbspace
- xp_enumdsn
- xp_enumerrorlogs
- Some Undocumented DBCC Commands
- sp_MSforeachtable
- sp_MSforeachDB
Usefull Admin stuff For The Developer
No comments:
Post a Comment