Re: 'select case' in stored procedure ?
From: Agnes (agnes_at_dynamictech.com.hk)
Date: 07/21/04
- Next message: simon: "Combine 2 text values"
- Previous message: yaniv cohen: "RE: Comparing table structure?"
- In reply to: Narayana Vyas Kondreddi: "Re: 'select case' in stored procedure ?"
- Next in thread: Louis Davidson: "Re: 'select case' in stored procedure ?"
- Reply: Louis Davidson: "Re: 'select case' in stored procedure ?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 21 Jul 2004 15:32:38 +0800
I need to specified the column ??
infact, i got several column may be update (which depends on the case
parameter)
it seems wrong syntax if my code like this :-
update mytable
case @type
when 'A' then a = a + 1
when 'B' then b = b + 1
end
"Narayana Vyas Kondreddi" <answer_me@hotmail.com> 在郵件
news:u$7yJJvbEHA.2292@TK2MSFTNGP09.phx.gbl 中撰寫...
> Yes, something like this:
>
> UPDATE TableName
> SET ColumnName = CASE WHEN <Condition1> THEN <Value1> WHEN <Condition2>
THEN
> 'Value2' ELSE 'Value3' END
> WHERE <Some condition to select the rows>
> --
> Vyas, MVP (SQL Server)
> http://vyaskn.tripod.com/
>
>
> "Agnes" <agnes@dynamictech.com.hk> wrote in message
> news:%23EBiSjubEHA.1644@tk2msftngp13.phx.gbl...
> > How about update statment ?
> > After i select * from table, i need to update it at once.. but It
depends
> on
> > the condition,
> > Can update got the 'case' also ??
> >
> > "Agnes" <agnes@dynamictech.com.hk> 在郵件
> > news:eiIlaFubEHA.2812@tk2msftngp13.phx.gbl 中撰寫...
> > > I understand and try it later . Thanks
> > > this syntax seems quit useful. as i don't need to create several store
> > > procedure
> > > "Narayana Vyas Kondreddi" <answer_me@hotmail.com> 在郵件
> > > news:eXnTy4mbEHA.3596@tk2msftngp13.phx.gbl 中撰寫...
> > > > A quick example:
> > > >
> > > > SELECT EmpID, EmpName,
> > > > CASE Sex
> > > > WHEN 'm' THEN 'Male'
> > > > WHEN 'f' THEN 'Female'
> > > > ELSE 'Unspecified'
> > > > END AS 'Sex'
> > > > FROM Employees
> > > >
> > > > --
> > > > HTH,
> > > > Vyas, MVP (SQL Server)
> > > > http://vyaskn.tripod.com/
> > > > Is .NET important for a database professional?
> > > > http://vyaskn.tripod.com/poll.htm
> > > >
> > > >
> > > > "Agnes" <agnes@dynamictech.com.hk> wrote in message
> > > > news:un8wE0mbEHA.3096@tk2msftngp13.phx.gbl...
> > > > Can I use select case in "stored procedure ???
> > > > If yes, can someone be kind to give me a sample ??
> > > > Thanks
> > > > From SQL-newbie
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
- Next message: simon: "Combine 2 text values"
- Previous message: yaniv cohen: "RE: Comparing table structure?"
- In reply to: Narayana Vyas Kondreddi: "Re: 'select case' in stored procedure ?"
- Next in thread: Louis Davidson: "Re: 'select case' in stored procedure ?"
- Reply: Louis Davidson: "Re: 'select case' in stored procedure ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|