Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

declare [local variable] as type TABLE

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I don't arrive to declare a local variable as type table.
I tried 3 hours with the documentation of Microsoft.
No sample for that.
I'm using MS SQL7.0 und 2K.

I write stored procedures and must absolutely avoid temporary tables.
 
I am fairly sure what you want to do is not possible in 7. In 2000 you can create a user function which can return a table variable. Look at user defined functions in the BOL docs for 2000.

Just out of curiousity, what is the problem with temp. tables?
 

Fluteplr is correct. Table variables were introduced in SQL 2000.

Here is a simple example of T-SQL using a table variable.

Declare @tblvar table
(LastName varchar(30),
FirstName Varchar(30),
Address varchar(40))

Insert @tblvar
Select Lastname, FirstName, Address
From dbo.AddressesTbl
Where ZipCode='20202'

Update @tblvar Set Address=Upper(Address)

Select * From @tblvar Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 

I have two recommendations.

1) Join Tek-Tips.
2) Ask questions about Microsoft SQL Server in forum183. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Thanks for your replies.
Meanwhile I recignized that it's available since MS SQL SERVER 2000.

Why using this? RAM is so cheap, and the performance win is so high, you can speed up stored procedeures...

Bye everybody
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top