use jscript Create a SQL Server database_javascript技巧
程序员文章站
2022-04-15 10:40:38
...
Create a SQL Server database.
DB_SIZE_IN_MEGABYTES = 5
strDBServerName = "."
Set objSQLServer = CreateObject("SQLDMO.SQLServer")
objSQLServer.LoginSecure = True
objSQLServer.Connect strDBServerName
Set objDB = CreateObject("SQLDMO.Database")
Set objFG = CreateObject("SQLDMO.Filegroup")
Set objDBFile = CreateObject("SQLDMO.DBFile")
Set objLogFile = CreateObject("SQLDMO.LogFile")
objDB.Name = "ScriptingGuysTestDB"
objDBFile.Name = "ScriptingGuysTestDB_Data"
objDBFile.PhysicalName = "C:\Program Files\Microsoft SQL Server\MSSQL\data\ScriptingGuysTestDB_Data.MDF"
objDBFile.Size = DB_SIZE_IN_MEGABYTES
objDB.FileGroups("PRIMARY").DBFiles.Add(objDBFile)
objSQLServer.Databases.Add(objDB)
复制代码 代码如下:
DB_SIZE_IN_MEGABYTES = 5
strDBServerName = "."
Set objSQLServer = CreateObject("SQLDMO.SQLServer")
objSQLServer.LoginSecure = True
objSQLServer.Connect strDBServerName
Set objDB = CreateObject("SQLDMO.Database")
Set objFG = CreateObject("SQLDMO.Filegroup")
Set objDBFile = CreateObject("SQLDMO.DBFile")
Set objLogFile = CreateObject("SQLDMO.LogFile")
objDB.Name = "ScriptingGuysTestDB"
objDBFile.Name = "ScriptingGuysTestDB_Data"
objDBFile.PhysicalName = "C:\Program Files\Microsoft SQL Server\MSSQL\data\ScriptingGuysTestDB_Data.MDF"
objDBFile.Size = DB_SIZE_IN_MEGABYTES
objDB.FileGroups("PRIMARY").DBFiles.Add(objDBFile)
objSQLServer.Databases.Add(objDB)
推荐阅读
-
use jscript with List Proxy Server Information_javascript技巧
-
use jscript with List Proxy Server Information_javascript技巧
-
use jscript Create a SQL Server database_javascript技巧
-
Sample script that deletes a SQL Server database_javascript技巧
-
use jscript Create a SQL Server database_javascript技巧
-
Sample script that deletes a SQL Server database_javascript技巧