[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-03-24
Medium Priority
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
Question by:uzairp
  • 2
LVL 14

Accepted Solution

nayernaguib earned 1000 total points
ID: 16287418
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
LVL 14

Expert Comment

ID: 16287449
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 Comment

ID: 16296866
Now I know I dont have to spend any more time looking for an equivalent of rowtype. Thanks

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question