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)
 Creating a Table using Stored Procedure Where Table name is based on user input

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-18 : 18:23:00
Benjamin writes "I am trying to creat a Stored Procedure to create a table where the table name is based on user input and with the "_inventory" added to the name. In my situation, I am trying to create a table for every company has registered online. for example, if the company name = microsoft, and the result of the table name would be "microsoft_inventory". I tried to create the procedure with the following code:

CREATE PROCEDURE sp_CompInv
@name nvarchar (60)
AS
CREATE TABLE @name"_inventory" (
inventoryID int(4) IDENTITY (1,1) NOT NULL,
companyID int(4) null,
productID int(4) null
)
GO

Thanks!!

I am using SQL7.0 on NT4.0 with sp5."
   

- Advertisement -