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

jwcolby jwcolby at colbyconsulting.com
Sat Jun 2 08:37:28 CDT 2007


I'll give it a try. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stephen
Hait
Sent: Saturday, June 02, 2007 7:25 AM
To: dba-sqlserver at databaseadvisors.com
Subject: Re: [dba-SQLServer] SQL Server 2005 - Build a table in a
databaseusing a stored procedure

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
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list