I am new to stored procedures, but seems to me what I am trying to do should be easy. Basically just want to check if table exists, drop it if it does, and recreate it.
When I create the stored proc, it truncates the statement after the first GO (after drop table). Can someone please tell me why it will not work as entered below? btw, this is happening with several of my attempts to create stored procedures, so hopefully the answer will help me with the rest.
Here is the stuff:
server is SQL 2000, SP3
Thanks
Jimmie
When I create the stored proc, it truncates the statement after the first GO (after drop table). Can someone please tell me why it will not work as entered below? btw, this is happening with several of my attempts to create stored procedures, so hopefully the answer will help me with the rest.
Here is the stuff:
Code:
CREATE PROCEDURE dbo.usp_AM_dropcreate_table AS
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AuditMaintTemp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AuditMaintTemp]
GO
CREATE TABLE [dbo].[AuditMaintTemp] (
[AuditMaintTempID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[AcctNbr] [numeric](18, 0) Default 0 NOT NULL ,
[PayeeCode] [numeric](18, 0) Default 0 NOT NULL ,
[Cusip] [nvarchar] (10) Default ' ' COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[MaintType] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
server is SQL 2000, SP3
Thanks
Jimmie