Jump to content

Variables in Stored Procedures


jesh

Recommended Posts

I have to perform some logic in a stored procedure based on the values in a particular table. I know that I can do this to assign some values to two variables:

DECLARE @value1 intDECLARE @value2 intSET @value1 = (SELECT column1 FROM mytable WHERE id=5)SET @value2 = (SELECT column2 FROM mytable WHERE id=5)

Does anyone know whether or not I can do the above with a single select statement rather than having to run two selects against the same table to fetch two different columns in the same row?DBMS is SQL Server 2005.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...