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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 creating tables using parameter values
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 06/05/2002 :  09:32:28  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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

USA
992 Posts

Posted - 06/05/2002 :  09:36:54  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000