krishna kumar
krishna kumar

Reputation: 153

Update query using select statement of updating table

In Mssql i want to update a column col1 in table named Table1 using select query which returns col1 from Table1 and add 1 to it. So i used the following code

update Table1 set col1=(select col1 from Table1) + 1;

But when i used it says you cannot target same table.Is there any ways to work out this function. Please help to find it out.

Thanks in advsnce

Upvotes: 1

Views: 700

Answers (1)

echo_Me
echo_Me

Reputation: 37243

you can do it like that

     update Table1 set col1= col1 + 1;

Upvotes: 2

Related Questions