select case statement in vba

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Does anyone know what the SQL Server 2000 equivalent, if
there is any, would be to the Access VBA Select Case
statement? For example code in VBA would be.

Dim SomeVariable As Integer

Select Case SomeVariable
Case 1
'Do this
Case 2
'Do that
Case Else
'Do all
End Select

Thanks, Dave
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



It would be CASE ... WHEN ... THEN ... ELSE ... END. E.g.:

CASE @SomeVariable
WHEN 1 THEN -- do this
WHEN 2 THEN -- do that
ELSE -- do something else
END

See the SQL'r Books On Line (BOL) article on CASE for more info.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQIiJ8oechKqOuFEgEQLUygCgv7GsLDv4m0pTI+rYgggbPlRjARQAoOxb
5wlDpGl+i6oqvgw2pClEJtwt
=T9of
-----END PGP SIGNATURE-----
 
thanks for the response. i tried that exact code and it
kept bombing on me in query anaylzer, since it wasn't
being used as a complete sql select statement. for
example it wanted me to use it like...

select case fieldname when...then...else...end as
newfieldname from sometable

thanks, dave
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What, specifically, are you trying to do? It's easier to supply a
solution for a specific problem. That's why I referred you to the BOL
article for more info if my previous solution failed or did not suit
your purposes.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQImVjYechKqOuFEgEQK6lQCg/4bARkG9rhCzCtrS4kEmw5sXkg0AnR5Y
pOtS4Sl/AhlFvtxQaqAOojjm
=yTHg
-----END PGP SIGNATURE-----
 
Back
Top