We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Sql server-t-sql: how do I declare table datatype and fetch a cursor into it?

uzairp
uzairp asked
on
Medium Priority
607 Views
Last Modified: 2012-06-27
Hi experts,
I am writing a stored procedure in sql server and instead of declaring so many local variable to hold the resultset from a cursor, I want to be able to declare a rowtype or tabletype datatype to hold the resultset. I am new to sql server but have worked with Oracle database.
Can someone please help alongwith code examples? Thanks
/uzairp
Comment
Watch Question

This question comes usually from Oracle to SQL Server newcomers. :-)

Unfortunately, There's no way to declare a %ROWTYPE variable in SQL Server. You need to declare as many variables as needed to hold values from a record.

_______________

  Nayer Naguib

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Here's what "Microsoft SQL Server Migration Assistant for Oracle" says:

• Variable declarations including %ROWTYPE on Oracle will be converted to a group of local variables on SQL Server.

_______________

  Nayer Naguib

Author

Commented:
Now I know I dont have to spend any more time looking for an equivalent of rowtype. Thanks
/uzairp
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.