Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update column information

Tags:

sql

sql-update

I am trying to update information in the column Mgrstat to a 3 and would like to mass enter the information. As it is I have to use "=" and enter each AppID individually but I would rather enter several at once. The query below shows my attempt using "in", which didn't work either. I get "Incorrect syntax near the keword 'in'".

Any ideas? Thanks everyone!

declare @appid as int
declare @mgrstat as int

set @appid in ('10995',
'11201',
'9523',
'9558',
'9666',
'10069',
'10547',
'10548',
'9702',
'10698',
'9754',
'10161',
'10162',
'11240',
'11241',
'9553',
'10848',
'10667',
'9383',
'10709',
'9696',
'10053',
'10702')
set @mgrstat = 3


update [Compensation].[dbo].[dev_RPT_Approval]
set Mgr_Stat = @mgrstat
 FROM [Compensation].[dbo].[dev_RPT_Approval]
  where @appid = App_Id

  select *
  from [Compensation].[dbo].[dev_RPT_Approval]
  where @appid = App_Id
like image 660
MHeath Avatar asked May 01 '26 03:05

MHeath


1 Answers

This is the SQL you Need:

update dev_RPT_Approval set Mgr_Stat=3 
where designation
in ('10995',
'11201',
'9523',
'9558',
'9666',
'10069',
'10547',
'10548',
'9702',
'10698',
'9754',
'10161',
'10162',
'11240',
'11241',
'9553',
'10848',
'10667',
'9383',
'10709',
'9696',
'10053',
'10702')
like image 108
Tirma Avatar answered May 02 '26 20:05

Tirma