filthy_mcnasty
June 15th, 2009, 06:50 PM
Hi
Basically I want to write a stored procedure that will update data across 2+ different tables but the data will be in one or the other, not both. Please assume I can determine WHICH table the data I'm looking for is in....
I'm hoping to do something like:
declare @temptbl table
if(@row_count > 0)
begin
set @temptbl = db.schema.tablename
end
else
begin
set @temptbl = db.schema.backupdata
end
update @temptbl
set bla = 'bla'
Basically I'd like to avoid having 4000 nests of boolean logic here. Is there an easy way to do something like this WITHOUT modifying the data structure? (i cannot create a view w/ partition)
Basically I want to write a stored procedure that will update data across 2+ different tables but the data will be in one or the other, not both. Please assume I can determine WHICH table the data I'm looking for is in....
I'm hoping to do something like:
declare @temptbl table
if(@row_count > 0)
begin
set @temptbl = db.schema.tablename
end
else
begin
set @temptbl = db.schema.backupdata
end
update @temptbl
set bla = 'bla'
Basically I'd like to avoid having 4000 nests of boolean logic here. Is there an easy way to do something like this WITHOUT modifying the data structure? (i cannot create a view w/ partition)