Link to home
Start Free TrialLog in
Avatar of searchsanjaysharma
searchsanjaysharma

asked on

How to update multiples tables with similar values with single update command.

update mstchvs set quarter='P1' where ltrim(rtrim(month)) in('October','November','December') and year=2010

I want to do this similar update from t1,t2,t3,t4


How to achieve this.
Avatar of mr-kenny
mr-kenny
Flag of Switzerland image

I not understand exactly what to want to do. Do you want to use variables?

DECLARE @i1 INT

SET @i1 = 100

DECLARE @string11 NVARCHAR(50)

SET @string11 = 'MyString'

SELECT * FROM dbo.t1 WHERE dbo.t1.Col1 = @i1
SOLUTION
Avatar of Zberteoc
Zberteoc
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
With Dynamic SQL it would be possible to use varibles for tables and columns but I also suggest to use separate Update Statements instead of dynamic Sql.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of searchsanjaysharma
searchsanjaysharma

ASKER

This i was already doing it. But i liked comment by jimhorn, Thanks to all.