Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help Please

Author  Topic 

Rollie
Starting Member

4 Posts

Posted - 2012-10-04 : 21:55:50
guys, need your help on this please.

I need to update all status into I which is inactive with the given data which is card no only. I am using SQL 2005

table name: Temp
id name card no status
1 Celso 5306722 A
2 andrew 5306724 A
3 albert 5306723 A
4 allan 5306735 A
5 Brian 5306774 A
6 Joseph 5306796 A
7 stephen 5306801 A

here is the result

Celso 5306722 I
Allan 5306735 I
Joseph 5306796 I
Stephen 5306801 I

My Query

Update From Temp
Set Status = 'I'
where card_no = '5306722, 5306735, 5306796, 5306801'

but it doesn't work

Thanks for the help guys.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-10-05 : 00:50:56
where card_no in (5306722, 5306735, 5306796, 5306801)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Rollie
Starting Member

4 Posts

Posted - 2012-10-05 : 01:29:48
Thank you for your reply tkizer but i keep getting this error

Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.

Im using SQL Server Manager Studio Express

Thanks again hope you can help with this.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-10-05 : 01:56:24
quote:
Originally posted by Rollie

Thank you for your reply tkizer but i keep getting this error

Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.

Im using SQL Server Manager Studio Express

Thanks again hope you can help with this.



If Card_no is of varchar type, then apply

where card_no in ('5306722', '5306735', '5306796', '5306801')

--
Chandu
Go to Top of Page

Rollie
Starting Member

4 Posts

Posted - 2012-10-05 : 02:04:59
tkizer:

i figured it out the correct syntax was where card_no in ('5306722', '5306735', '5306796', '5306801')
it work.

Thanks a lot. God bless
Go to Top of Page

Rollie
Starting Member

4 Posts

Posted - 2012-10-05 : 02:06:43
Thanks bandi your right.
it work already.

Thanks a lot guys.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-10-05 : 02:44:19
quote:
Originally posted by Rollie

Thanks bandi your right.
it work already.

Thanks a lot guys.




Welcome

--
Chandu
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-10-05 : 14:43:39
Rollie, why are you using varchar data type for numeric data?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -