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
 possible to update three condions at a time

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-04-11 : 06:33:53
hi,
i need to update my table values with difference condions at a time

example:

"update ChSetting set Interrupted_Level=" & CInt(ThresholdControl22.HeightThresholdBox) & " where Interrupted_Decition='" & intSensorSerialNo & "' and Interrupted_Decition='1')"
"update ChSetting set Interrupted_Level=" & CInt(ThresholdControl23.HeightThresholdBox) & " where Interrupted_Decition='" & intSensorSerialNo & "' and Interrupted_Decition='0')"
"update ChSetting set Interrupted_Level=" & CInt(ThresholdControl24.HeightThresholdBox) & " where Interrupted_Decition='" & intSensorSerialNo & "' and Interrupted_Decition='2')"



if means please give me some sample wa to do this please

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-11 : 06:45:35
do you know how to write a CASE expression?

Em
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-04-11 : 06:50:29
yes i know friend but in this situation i need help please give me sample query
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-11 : 06:53:50
Don't use dynamically build sql statements. Make use of stored proc.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-04-11 : 06:58:07
ok friend thanks for the reply
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-04-13 : 01:47:10
[code]
update ChSetting
set Interrupted_Level=
case
when Interrupted_Decition=0 then 'aaa'
when Interrupted_Decition=1 then 'bbb'
when Interrupted_Decition=2 then 'ccc'
end
where Interrupted_Decition in (0,1,2)
[/code]




elsasoft.org
Go to Top of Page
   

- Advertisement -