August 12, 2008 at 1:25 pm
I have the following code that is part of a larger script that runs against several tables cleaning data.
declare @oldcomment varchar;
declare @newcomment varchar;
if stgCustPmt.TranCmnt is not null
begin
set @oldcomment = stgCustPmt.TranCmnt;
set @newcomment = 'OldPmtNo: ' + cast(stgCustPmt.TranCmnt as varchar) + ' Cmt: ' + @oldcomment;
update stgCustPmt
set TranCmnt = @newcomment;
end
else
begin
set @newcomment = 'OldPmtNo: ' + cast(stgCustPmt.TranCmnt as varchar)
update stgCustPmt
set TranCmnt = @newcomment;
end
when I run this code segment, I get the error. any help would be appreciated. I get the error for each of the table.column entries.
August 12, 2008 at 1:36 pm
You can't reference a column in a table without a select, update, or delete FROM table. You are saying:
IF table.column then
And SQL Server has no idea what table.column is. You need to create a variable that holds the column and do a:
Select @column = column from table
Then you do:
If @column = x
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 12, 2008 at 1:49 pm
Ok, that at least got me past my errors, now working out the logic.
Thanks.
Phillip
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply