Subject | Create tables using a stored procedure |
---|---|
Author | Jose Luis Blanco |
Post date | 2008-01-25T06:20:15Z |
Hi:
I am writing an application that will handle all database
transactions via stored procedures, including creating tables. I
cannot get the following script to run, unless I place the CREATE
TABLE commands into variables and then use the EXECUTE command.
Can this be done in this manner?
-- Function: Custom stored procedure to create the lesson tables
-- STEP 1. Set the command termination character
SET TERM !! ;
-- STEP 2. Create the procedure name
CREATE PROCEDURE SP_CREATEPERSONNEL
AS BEGIN
CREATE TABLE LESSON (
NAME VARCHAR(255),
POSITION VARCHAR(255),
DEPARTMENT VARCHAR(255),
UNIT VARCHAR(3),
LEVEL VARCHAR(25)) !!
-- STEP 2. End the procedure
END!!
-- STEP 4. Reset the termination character
SET TERM ; !!
I am writing an application that will handle all database
transactions via stored procedures, including creating tables. I
cannot get the following script to run, unless I place the CREATE
TABLE commands into variables and then use the EXECUTE command.
Can this be done in this manner?
-- Function: Custom stored procedure to create the lesson tables
-- STEP 1. Set the command termination character
SET TERM !! ;
-- STEP 2. Create the procedure name
CREATE PROCEDURE SP_CREATEPERSONNEL
AS BEGIN
CREATE TABLE LESSON (
NAME VARCHAR(255),
POSITION VARCHAR(255),
DEPARTMENT VARCHAR(255),
UNIT VARCHAR(3),
LEVEL VARCHAR(25)) !!
-- STEP 2. End the procedure
END!!
-- STEP 4. Reset the termination character
SET TERM ; !!