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, 06: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 15 m 49 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 09:26 PM.

Reply With Quote
  #2  
Old January 18th, 2007, 02: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, 02: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, 09: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, 02: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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





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