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 2000 Forums
 SQL Server Development (2000)
 Use IN function to pick up SMALLDATETIME

Author  Topic 

wangyc77
Yak Posting Veteran

65 Posts

Posted - 2007-02-08 : 20:48:11
SAMPLE DATA HolidayLookup
holiday
------------------------------------------------------
2006-09-22 00:00:00
2006-10-08 00:00:00
2006-11-02 00:00:00
2006-11-22 00:00:00
2006-12-22 00:00:00
2007-01-01 00:00:00
2007-01-07 00:00:00
2007-02-10 00:00:00

I tried this
------------------
declare @h table (holiday SMALLDATETIME)
INSERT @h
select Holiday From HolidayLookup
select * from @h

-- something to start with
IF ( '2007/1/1' IN ( @h))
PRINT 'OK'
-----------------------
But it seems that I will get an error at @h
the purpose that I used a temperary @h instead of using [select Holiday From HolidayLookup] is to increase performance. Because @h's data will be used many times and I don't want to call [select Holiday From HolidayLookup] everytime I need it .

Please help

**Jonathan**

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-08 : 22:07:30
You still have to do select Holiday from @h. So it makes no difference.


-- something to start with
IF ( '2007/1/1' IN ( select Holiday from @h))
PRINT 'OK'



KH

Go to Top of Page
   

- Advertisement -