Hallo
Hope all are well.
I always done the code in c# but want to move execute the command via stored procedures, currently it's still very confusing with the begin and end instructions.
I want to be able to execute multiple task as follow:
Want to create a temp table if not exist, if not I need to create the table and then want to do a insert into statement.
I get error obviously, I use the script editor to get the correct code, but where do I put what, some guidelines will be appreciated.
USE [BusinessDataSQL] GO CREATE PROCEDURE DumpToTempTable AS BEGIN /****** Object: Table [dbo].[TempPricelist] Script Date: 09/26/2015 10:15:20 ******/ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TempPricelist]') AND type in (N'U')) DROP TABLE [dbo].[TempPricelist] END BEGIN /****** Object: Table [dbo].[TempPricelist] Script Date: 09/26/2015 10:15:20 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING OFF GO CREATE TABLE [dbo].[TempPricelist]( [TempID] [bigint] IDENTITY(1,1) NOT NULL, [PartNumber] [varchar](50) NULL, [PartName] [varchar](50) NULL, [PartDescrip] [varchar](50) NULL, [Cost] [varchar](50) NULL, [TarriffCode] [varchar](50) NULL, CONSTRAINT [PK_TempPricelist] PRIMARY KEY CLUSTERED ( [TempID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO END
labjac