??????????

???????DBA???????????????????SQL????????????????????????????????????????????????DBA??е????????????м????sql????????????????????????????????????????????????????????????????????洢?????????????????????????н???????3???????????????????????????????????й???Σ??????????????????????????????

?????????????

????????????????????????????

????1?????????????????????????????

????2???????????С???????У???????????????????????????????????????Σ???????????С?

????3?????????????????????????????????

???????SQLCMD??SQLServer????ж???????

????SQLCMD????? sqlcmd ??ù????????????????????????? SQLCMD ???μ?“???????”?С??? Windows ???????л????? SQL Server ?????????????? ??Cmd.exe?? ????????????? Transact-SQL ????????????????? ????ù?????? ODBC ??? Transact-SQL ??????????????MSDN????????????????????????????????

????SQLCMD????????????????:r???????SQLCMD???Сд??е??????r????????????SQL????????????SQLCMD???????????????????????????y???С????????????????????????????μ????????????ù???????????????λ?á?????????r???????????????????ж????????????????????????????????????????????н?????????????GO????????2005???????SQLCMD????????????????osql?????????????SQLCMD???????????????????????????T-SQL??????????????й????

?????????????У?????5????????TestDB????????й?????sql?????????????????CREATE_DB.sql????????????????TestDB???????????????????4??????????????????r?????????????????????????????????????洢?????????????.bat?????????????????SQLCMD???

?????????????????????C???μ?????У?C:Scripts?????????????????????У?

???????1??CREATE_DB.sql


/* SCRIPT: CREATE_DB.sql */
/* ????TestDB????? */

-- This is the main caller for each script
SET NOCOUNT ON
GO

PRINT '???????TestDB?????'
IF EXISTS (SELECT 1 FROM SYS.DATABASES WHERE NAME = 'TestDB')
DROP DATABASE TestDB
GO
CREATE DATABASE TestDB
GO

:On Error exit

:r c:ScriptsCREATE_TABLES.sql
:r c:ScriptsTABLE_INSERTS.sql
:r c:ScriptsCREATE_INDEXES.sql
:r c:ScriptsCREATE_PROCEDURES.sql

PRINT '???????'
GO