T-SQL in sql 2008 -
T-SQL in sql 2008 -
i trying next in sql 2008.
here logic :
table 1 source table.
if match (domain & company & country) table 2 -> update price
else
if match (domain) table 3 -> update price
else if match (domain) table 2 -> update price
else if match (company & country) table 2 -> update price
if match 1 of above condition, update cost in source table.
how should loop source table ? there may lot records in source table.
thanks in advance.
something should think:
update t1 set cost = case when t2.id not null t2.price when t3.id not null t3.price when t22.id not null t22.price else t1.price end [table 1] t1 left bring together [table 2] t2 on t1.company = t2.company , t1.country = t2.country , substring(t1.email, charindex('@', t1.email) + 1, len(t1.email)) = t2.domain left bring together [table 3] t3 on substring(t1.email, charindex('@', t1.email) + 1, len(t1.email)) = t3.domain left bring together [table 2] t22 on t1.company = t2.company , t1.country = t2.country
sql-server-2008
Comments
Post a Comment