February 4, 2003 at 8:32 am
Hi guys,
I want to do something very simple: Here it goes:
I create a table, then I am going to populate it based on a few things. The column I am populating in the new table is based off of the datetime value in the source table.
So in other words,
CREAT TABLE #Example
( RecordID int not null,
NewColInd bit not null
)
EXEC
('
INSERT INTO #Example
SELECT sourcetbl.recordid AS RecordID,
(CASE datetimecol
WHEN datetimecol IS NOT NULL
THEN 1
ELSE 0
END) AS NewColInd
')
How do I correctly write this? (I excluded the joins for this writing, of course they exist in actual sql)
Thanks for your hep.
February 4, 2003 at 9:04 am
You don't need the EXEC('').
You also need to include the FROM (and possibly WHERE clauses) although, I think your second statement alludes to you just leaving them off the script..?
February 4, 2003 at 9:09 am
Thanks jpipes, yes I left off the where and from clauses for these purposes. I'm only interested in the eror I'm getting from the CAE statement.
It really doesn't make much of a difference about the "EXEC (' " it will run regardless.
I just need some input on that dangnabbitt CASE ststement.
Thanks again,
Chris
February 4, 2003 at 9:11 am
Try:
CASE
WHEN datetimecol IS NOT NULL THEN 1 ELSE 0 END
🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply