使用SQLCMD在SQL Server执行多个脚本
作者:网络转载 发布时间:[ 2012/12/24 10:19:56 ] 推荐标签:
脚本2:CREATE_INDEXES.sql
/* 创建索引 */
PRINT '开始创建索引'
GO
USE TestDB
GO
IF NOT EXISTS ( SELECT 1
FROM SYS.INDEXES
WHERE NAME = 'IX_EMPLOYEE_LASTNAME' )
CREATE INDEX IX_EMPLOYEE_LASTNAME ON DBO.EMPLOYEE(LASTNAME, FIRSTNAME)
GO
IF NOT EXISTS ( SELECT 1
FROM SYS.INDEXES
WHERE NAME = 'IX_TIMECARD_EMPLOYEEID' )
CREATE INDEX IX_TIMECARD_EMPLOYEEID ON DBO.TIMECARD(EMPLOYEEID)
GO
脚本3:CREATE_PROCEDURES.sql
/* 创建存储过程 */
PRINT '正在创建存储过程'
GO
USE TestDB
GO
IF OBJECT_ID('GET_EMPLOYEE_TIMECARDS') IS NOT NULL
DROP PROCEDURE DBO.GET_EMPLOYEE_TIMECARDS
GO
CREATE PROCEDURE DBO.GET_EMPLOYEE_TIMECARDS @EMPLOYEEID INT
AS
SET NOCOUNT ON
SELECT *
FROM DBO.EMPLOYEE E
JOIN DBO.TIMECARD T ON E.EMPLOYEEID = T.EMPLOYEEID
WHERE E.EMPLOYEEID = @EMPLOYEEID
ORDER BY DATEWORKED
GO
脚本4:CREATE_TABLES.sql
/* 创建数据表 */
PRINT '正在创建数据表 '
GO
USE TestDB
GO
IF OBJECT_ID('EMPLOYEE') IS NOT NULL
DROP TABLE DBO.EMPLOYEE
GO
CREATE TABLE DBO.EMPLOYEE
(
EMPLOYEEID INT IDENTITY(1, 1)
NOT NULL
PRIMARY KEY ,
FIRSTNAME VARCHAR(50) ,
LASTNAME VARCHAR(50)
)
GO
IF OBJECT_ID('TIMECARD') IS NOT NULL
DROP TABLE DBO.TIMECARD
GO
CREATE TABLE DBO.TIMECARD
(
TIMECARDID INT IDENTITY(1, 1)
NOT NULL
PRIMARY KEY ,
EMPLOYEEID INT NOT NULL ,
HOURSWORKED TINYINT NOT NULL ,
HOURLYRATE MONEY NOT NULL ,
DATEWORKED DATETIME NOT NULL
)
GO
DECLARE @TOTAL_TABLES INT
SET @TOTAL_TABLES = 2
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11