Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
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:
  #1  
Old January 16th, 2005, 05:42 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 15th Plane (12000 - 12499 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 12,025 Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level)Memnoch User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 3 Weeks 6 Days 12 h 21 m 3 sec
Reputation Power: 628
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: 932 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 16 h 32 m 39 sec
Reputation Power: 326
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
  #5  
Old January 30th, 2009, 01:28 AM
dimple dimple is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 3 dimple User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 50 m 15 sec
Reputation Power: 0
Quote:
Originally Posted by bzlomke
What is the default value for a Date field that hasn't been filled?

TIA,

Brad Z.


MySQL does not allow setting the default value of a column to an expression. TIMESTAMP columns are a limited exception. A simple trigger is something like this:

CREATE TRIGGER triggerName
BEFORE INSERT ON yourTable
FOR EACH ROW
SET NEW.date = curdate();

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!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

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





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek