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.
| Author |
Topic |
|
barnabeck
Posting Yak Master
236 Posts |
Posted - 2012-05-30 : 07:26:56
|
The database WORKCALENDAR has records only for working days.I want to declare a variable that is '1' in case that the query that checks if today is a workingday returns a match or '0' in case it doesn't.declare @workday binaryset @workday = ..??... from dbo.WORKCALENDAR where DATEDIFF(day, TRANSDATE, GETDATE()) =0 I've been trying with ISNULL in the last hour but I just don't get it.What function does this trick?Martin |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-05-30 : 07:32:22
|
| declare @workday int = 0select @workday = 1 from dbo.WORKCALENDAR where DATEDIFF(day, TRANSDATE, GETDATE()) =0==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
barnabeck
Posting Yak Master
236 Posts |
Posted - 2012-05-30 : 07:43:48
|
| yeah... close but not close enough!Thank you Nigel |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-05-30 : 09:00:40
|
declare @workday intset @workday = 0if exists(select * from dbo.Workcalendar where DATEDIFF(day, TRANSDATE, GETDATE()) =0)beginset @workday = 1end No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|