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 tables using parameter values

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-05 : 09:32:28
varun writes "I want to create a table using parameters
This is the stored procedure i have written, but when execute the stored procedure, i received this error.


CREATE PROC CreateTable @TableName char(10), @datevar char(10)

AS

SET @datevar = CONVERT(CHAR(10),Datepart(hh,getdate()))
SET @TableName = 'test' + @datevar

EXEC ('CREATE TABLE ' + @TableName + '([OrderID] [int] IDENTITY (1, 1) NOT NULL , [Description] [varchar] (255))' )
GO

Server: Msg 201, Level 16, State 4, Procedure CreateTable, Line 0
Procedure 'CreateTable' expects parameter '@datevar', which was not supplied.


I can able to create the table with the following code.

DECLARE @TableName char(10), @datevar char(10)
SET @datevar = CONVERT(CHAR(10),Datepart(hh,getdate()))
SET @TableName = 'test' + @datevar
EXEC ('CREATE TABLE ' + @TableName +
'([OrderID] [int] IDENTITY (1, 1) NOT NULL , [Description] [varchar] (255))' )"

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-06-05 : 09:36:54
quote:

Server: Msg 201, Level 16, State 4, Procedure CreateTable, Line 0
Procedure 'CreateTable' expects parameter '@datevar', which was not supplied.



What's your syntax for calling CreateTable? Are you passing in @datevar? (SQL Server doesn't think so)

setBasedIsTheTruepath
<O>
Go to Top of Page
   

- Advertisement -