[dba-SQLServer] SQL Server 2005 - Build a table in a database using a stored procedure

Stephen Hait shait at mindspring.com
Sat Jun 2 06:24:53 CDT 2007


On 6/2/07, jwcolby <jwcolby at colbyconsulting.com> wrote:
> CREATE TABLE [dbo].[tblDataMapCSVOut](
>         [CSVID] [int] IDENTITY(1,1) NOT NULL,
>         [CSVFldNameInTable] [varchar](50) COLLATE
> SQL_Latin1_General_CP1_CI_AS NULL,
>         [CSVFldNameInFile] [varchar](50) COLLATE
> SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]

<snip>

> Msg 154, Level 15, State 1, Procedure sp_CreateDataMapCSVOut, Line 16
> a USE database statement is not allowed in a procedure, function or trigger.
> Msg 102, Level 15, State 4, Line 1
> Incorrect syntax near 'ANSI_PADDING'.
>
> Is there a way to do this?  Can someone "fix me up" here so that this works?

I'm no expert but would it work if you did something like this instead
and skipped the USE?

CREATE TABLE [@DatabaseName].[dbo].[tblDataMapCSVOut]
...

-Stephen



More information about the dba-SQLServer mailing list