Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old January 16th, 2005, 05:42 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,672 Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level)Memnoch User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 6 h 1 m 55 sec
Reputation Power: 356
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:
Milliseconds = Ms
Second = Ss
Minute = Mi
Hour = Hh
Day of the Week = Dw
Day of the Month = Dd
Day of the Year = Dy
Week = Wk
Month = Mm
Quarter of the Year = Qq
Year = Yy


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.

Reply With Quote
  #2  
Old January 18th, 2007, 01:32 PM
bzlomke bzlomke is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 bzlomke User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 20 m 8 sec
Reputation Power: 0
Quote:
Originally Posted by Memnoch
Avoid using NULL values in your SQL Server databases.
Pertains to SQL Server 6.5 and higher


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.


What is the default value for a Date field that hasn't been filled?

TIA,

Brad Z.

Reply With Quote
  #3  
Old January 18th, 2007, 01:56 PM
asmoran asmoran is offline
ASPFree Know-It-All
ASP Free Novice (500 - 999 posts)
 
Join Date: Aug 2004
Posts: 930 asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level)asmoran User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 15 h 13 m 20 sec
Reputation Power: 324
1/1/1900

Reply With Quote
  #4  
Old January 2nd, 2008, 08:39 AM
harkiratsin harkiratsin is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 13 harkiratsin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 55 m 56 sec
Reputation Power: 0
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 ....?

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Microsoft SQL Server Tips


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway