dbTalk Databases Forums  

Finding values containing milli seconds!

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Finding values containing milli seconds! in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mohd Al Junaibi
 
Posts: n/a

Default Finding values containing milli seconds! - 05-23-2007 , 01:49 AM







Hi all...

I've got a group of tables and I wanted to first see which tables
contained a fields containing the "Date/Time" data type. And I was
successful in doing so...here's the query:


(
select a.name tablename, b.name colname
from sysobjects a, syscolumns b
where a.name = object_name(b.id)
AND B.TYPE = 61 AND A.XTYPE = 'U'

)


Now...my only issue is find which query I can run (On each table)
which returns to me ONLY the values containing the date/time stamp
with milli seconds (Ex: 01/01/2007 10:10:50:987)

I require this since we are planning on shifting those tables to the
Oracle platform, and we've had issues doing this while loading the
extracted information, since it was not taking the values containing
the "milliseconds".

Is there a way to do this? Or is it better to simply remove the
milliseconds all togeather? I wouldn't mind doing so provided that it
doesn't includes changes to the actual data type.


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Finding values containing milli seconds! - 05-23-2007 , 05:10 PM






Mohd Al Junaibi (mohamed.aljunaibi (AT) gmail (DOT) com) writes:
Quote:
I require this since we are planning on shifting those tables to the
Oracle platform, and we've had issues doing this while loading the
extracted information, since it was not taking the values containing
the "milliseconds".
SELECT datetimecol
FROM tbl
WHERE datepart(ms, datetimecol) <> 0

Quote:
Is there a way to do this? Or is it better to simply remove the
milliseconds all togeather? I wouldn't mind doing so provided that it
doesn't includes changes to the actual data type.
UPDATE tbl
SET datetimecol = dateadd(ms, -datepart(ms, datetimecol), datetimecol)
WHERE datepart(ms, datetimecol) <> 0

Caveat: I did not test this.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.