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 2005 Forums
 Transact-SQL (2005)
 [Resolved] Check db type dbtimestamp field

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2010-04-23 : 12:26:12
Is there is a way to check if timestamp field is Null or Nothing?

I tried this:

timestamp_field is Null or timestamp_field is Nothing


it gives error: Error converting data type DBTYPE_DBTIMESTAMP to datetime.

Thank you.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-23 : 12:33:00
I know "Nothing" from VB.
Is it possible to use it in T-SQL?
Have you tried
isnull(timestamp_field,'') <> ''


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2010-04-23 : 13:49:08
This is T-sql, I've tried every option I can think of. Maybe I need to convert the field to something else before I can check the value for Null. I'm not sure.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-23 : 13:51:35
"timestamp_field is Null" is correct.

Check it out with this simple test:

declare @t table (c1 int, c2 datetime)

insert into @t values(1, null)
insert into @t values(2, getdate())

select * from @t where c2 is null

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

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-23 : 13:52:22
Or is the timestamp_field not a date/time column?

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

Subscribe to my blog
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2010-04-26 : 11:29:23
It worked:

declare @t table (c1 int, c2 datetime)

insert into @t values(1, null)
insert into @t values(2, getdate())

select * from @t where c2 is null

I noticed there was something in the select that prevented me from getting the results.

Thank you guys.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-26 : 12:14:48


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

Subscribe to my blog
Go to Top of Page
   

- Advertisement -