How To Create Table Using Stored Procedure In MSSQL Database Server Tutorial Example
Run microsoft sql server management studio query editor or any client tools you like then copy & paste the below code to create an stored procedure to create a table usinq sql command or statement in MSSQL Database Server Tutorial Example
CREATE PROCEDURE [SP_TBL_CREATOR_EXECUTIVE]
AS
BEGIN
CREATE TABLE executives
(
lastname varchar(50) NOT NULL,
department varchar(50) NULL,
join_date date NULL,
salary numeric(18, 0) NOT NULL
) ON [PRIMARY]
END
Result in Microsoft Sql Server Management Studio Query Editor Client Tools :: Stored Procedure Created
Now we need to execute the stored procedure to a create table in MSSQL Database Server. To do so, run microsoft sql server management studio query editor or any client tools you like then copy & paste the below code.
/*
CREATE PROCEDURE [SP_TBL_CREATOR_EXECUTIVE]
AS
BEGIN
CREATE TABLE executives
(
lastname varchar(50) NOT NULL,
department varchar(50) NULL,
join_date date NULL,
salary numeric(18, 0) NOT NULL
) ON [PRIMARY]
END
*/
EXEC [SP_TBL_CREATOR_EXECUTIVE]
/* */ is multiline code comment :: before executing the stored procedure, make sure that you have created it. create the stored procedure [SP_TBL_CREATOR_EXECUTIVE] using blocked sql code, if it is not created yet. -- is comment in MSSQL -- in fact it is comment in Oracle and MySQL as well


No comments:
Post a Comment
leave your comments here..