I want to know, How can I store multiple rows in a variable.i.e. My query will return multiple rows and i want to store it in a variable.
Thanks in adv.
I want to know, How can I store multiple rows in a variable.i.e. My
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In SQL Server 2008, there’s a feature called Table Valued Parameters which allow you to store rows into a variable that can be passed across stored procedures.
If however, your intent is to manipulate the data inside the same store procedure, then common table variables would be fine. Here’s an Example:
@MyTableVariablenow contains all the rows matching the criteria, you can still continue to add more rows, do further manipulations and even return its contents.