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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure problem 1

Status
Not open for further replies.

stx

Programmer
Sep 24, 2002
62
BE
Hi

This is my stored procedure...

create procedure get_tableInfo
(
@tablename char(8)
)

as
select * from @tablename
return


This doesn't work.
What i want to do is returning a selection on a table in my database. The name of the table is given as a parameter.
Any thoughts?

thnx
 
Try this:

create procedure get_tableInfo
@tablename char(8)
as
select * from @tablename
 
Hi,

u wwill have to use dynamic SQL...
Have a look a FAQ183-3132

Something like this....
create procedure get_tableInfo
@tablename char(8)
as
Declare @SQL Varchar(1000)

SET @SQL = 'select * from ' + @tablename
Exec(@SQL)

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top