View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 06:31 PM
Jarrod Morrison
 
Posts: n/a
Default Stored Procedures Syntax

Hi All

Im still pretty new to using stored procedures and am not sure what syntax i
should be using. The variable @LocationID will be something along the lines
of 002, 003 and so on. What i want to do in the procedure is see if the
table already exists, and if so delete it (The code i have only works if
there is a record in the table). My problem with the syntax is that i want
to combine the word "Location" with the @LocationID variable when making the
new table and when checking if the table already exists but im unsure how to
combine the two for use in the procedure

Thanks in advance


/*
** Create New Location ID Table
*/

CREATE PROCEDURE [dbo].[CreateLocation]

@LocationID Char(3) /* New Location ID Number */

AS

IF EXISTS (SELECT * FROM (Location + @LocationID))
DROP TABLE [dbo].[(Location + @LocationID)]

CREATE TABLE [dbo].[(Location + @LocationID)](
[MachineName] [VarChar] (100) NOT NULL)
GO


Reply With Quote