use jscript Create a SQL Server database

2018-10-15 17:31

阅读:548

CreateaSQLServerdatabase.
复制代码 代码如下:
DB_SIZE_IN_MEGABYTES=5
strDBServerName=.

SetobjSQLServer=CreateObject(SQLDMO.SQLServer)
objSQLServer.LoginSecure=True

SetobjDB=CreateObject(SQLDMO.Database)
SetobjFG=CreateObject(SQLDMO.Filegroup)
SetobjDBFile=CreateObject(SQLDMO.DBFile)
SetobjLogFile=CreateObject(SQLDMO.LogFile)

objDBFile.Name=ScriptingGuysTestDB_Data
objDBFile.PhysicalName=C:\ProgramFiles\MicrosoftSQLServer\MSSQL\data\ScriptingGuysTestDB_Data.MDF
objDBFile.Size=DB_SIZE_IN_MEGABYTES

objDB.FileGroups(PRIMARY).DBFiles.Add(objDBFile)

objSQLServer.Databases.Add(objDB)



评论


亲,登录后才可以留言!