Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Date Validation Syntax

Author  Topic 

jscot
Posting Yak Master

106 Posts

Posted - 2011-06-23 : 21:28:39
I want to know is there any way or sql syntax you can run your date field to find out this field has valid dates, For example i had a problem, i was trying to import data from excel to sql but one date field giving me problem, The table has 60k records, What i find out one date row has '50022011' and that's giving me problem, I just want to know is there any sql syntax or way you can run against your date file? Thanks for reply.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-23 : 22:35:35
You can use the ISDATE function, which returns a boolean.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jscot
Posting Yak Master

106 Posts

Posted - 2011-06-23 : 23:54:18
tkizer thanks for reply, Could you please explain me little bit, select isdate(Field name) from table name? this syntax is work?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-23 : 23:59:20
BOL almost always has examples: http://msdn.microsoft.com/en-us/library/ms187347.aspx

You can also use it in the WHERE clause.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-06-29 : 07:04:07
If you have dates with specific formats you may need to check the length along with isdate function http://beyondrelational.com/blogs/madhivanan/archive/2007/09/24/handle-isdate-with-care.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -