|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
||||
|
||||
|
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 Cards ORDER 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. Last edited by Memnoch : January 2nd, 2006 at 08:26 PM. |
|
#2
|
|||
|
|||
|
Quote:
What is the default value for a Date field that hasn't been filled? TIA, Brad Z. |
|
#3
|
|||
|
|||
|
1/1/1900
|
|
#4
|
|||
|
|||
|
what will happen when I querry this from any dataset->tableadapter. Will this not force constraint error, whenever I will not use all non-null fields in my querry ....?
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Microsoft SQL Server Tips |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|