![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) | |
| Senior Member Join Date: Oct 2006 Location: new delhi
Posts: 183
Thanks: 21
Thanked 9 Times in 7 Posts
Rep Power: 6 | Microsoft SQL Server Tips Avoid using NULL values in your SQL Server databases. Pertains to SQL Server 6.5 and higher Here's a short list of some of the problems you can expect to encounter if you use NULLs in your database. 1) Client applications require extra programming logic to handle NULL values. 2) Calculation, sorting, comparison and grouping operations can handle NULL values in unexpected and counterintuitive ways. 3) Aggregates and join operations also exhibit unexpected or counterintuitive results (e.g., COUNT(*) and COUNT(MyField) produce different results). 4) NULL values can lead to undesirable results for WITH CUBE, WITH ROLLUP, and other statistical operations. 5) Nullable columns that contain NULL values cause a small but measurable sacrifice in performance since SQL Server has to perform an additional check to determine whether the column allows NULL values. Instead of allowing NULL values, you should set default values on your columns, such as 0 for numeric columns and an empty string ('') for text columns. ----------------------------------------------------------- Return SQL Server resultsets in random order Pertains to SQL Server 2000 and higher There may be times when you want to return the records of a query in random order, such as return card values in a poker game application. A quick way to do this is to use the NewID() function. Example: Code: SELECT *FROM CardsORDER BY NewID() ----------------------------------------------------------- Examine details about your SQL Server programmatically Pertains to SQL Server 2000 Code: SELECT SERVERPROPERTY('Edition')SELECT SERVERPROPERTY('IsSingleUser')SELECT SERVERPROPERTY('MachineName')SELECT SERVERPROPERTY('ProcessId')SELECT SERVERPROPERTY('ProductVersion')SELECT SERVERPROPERTY('ProductLevel')SELECT SERVERPROPERTY('ServerName') ----------------------------------------------------------- Use DATEPART to display individual protions of dates and times. Pertains to SQL Server 7.0 and higher Example: Code: PRINT DATEPART(Mm, GETDATE()) Constants that can be used Quote:
If you know of any other tips or tricks pertaining to Microsoft SQL Server, feel free to post them here so that others may learn from them.
__________________ Lalit Kumar 09914097899 ![]() | |
| | |
![]() |
| Tags |
| microsoft , server , sql , tips |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Some Loadrunner FAQs | kiran2710 | Testing Tools & QA | 1 | 25-10-08 12:42 AM |
| SQL Server 2005 Books Online (July 2006) | vjsreevs | ORACLE , SQL SERVER , SYBASE & Others | 2 | 11-07-08 02:01 AM |
| Microsoft SQL Server Administrator | sridhar | Fresher Jobs | 0 | 18-09-06 07:55 PM |
| hi..... | gomesh_2k6 | VB / ASP.NET Technologies | 8 | 07-09-06 12:38 PM |
| Servers | mahender9885 | Aptitude Questions | 2 | 21-02-06 03:02 AM |
| More Interview Questions Here... |