Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Input StoredProcedure

Author  Topic 

lengochao
Starting Member

1 Post

Posted - 2005-03-12 : 00:19:31
I'm facing a problem that makes me so sad
I want create a storedprocedure that access all fields of the table i supply name of the table like that
Create Procedure select_Table(@Table_Name text) As
Select *
From @Table_Name
But it doesn't work and i think that only work when you supply a specific name of the table like that "Person"
Create Procedure select_Table As
Select *
From Person
If what i think is corect ,i really have to create a lot storedprocedure that access all fields of many table
I you have some experiences about that,please show me.Thanks alot

Kristen
Test

22859 Posts

Posted - 2005-03-12 : 00:56:16
[code]
CREATE PROCEDURE select_Table
@Table_Name sysname
AS
DECLARE @strSQL varchar(8000)

SELECT @strSQL = 'SELECT * FROM ' + @Table_Name

EXEC (@strSQL)
[/code]
But I doubt this approach is a good idea ...

Kristen
Go to Top of Page
   

- Advertisement -