4

The code below works. Can this be improved?

declare @rlcstallname varchar(50), @rlcsalesdept varchar(50), @rlcpath varchar(50)

set @rlcstallname   = (select stallname from sometable)
set @rlcsalesdept   = (select salesdept from sometable)
set @rlcpath        = (select [path] from sometable)

I need to know how to get the three values I store into the variables using only one select statement; I find executing 3 select statements excessive.

Thanks

1

1 Answer 1

10
SELECT
    @rlcstallname = stallname,
    @rlcsalesdept = salesdept,
    @rlcpath = [path]
FROM sometable
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for this specific answer, wewesthemenace

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.