Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL stored proc gets truncated- structure problem? 1

Status
Not open for further replies.

topjimmie

IS-IT--Management
Feb 4, 2002
28
US
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:
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
 
GO signals the end of a batch. This includes CREATE PROCEDURE statements. Omit the GO or move it to the end of the procedure and SQL Server will compile the entire script. Good luck!


--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Hey, look at that, it works now!
Thanks a bunch for the assistance John.
Jimmie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top