?? sqlscripter.txt
字號:
SQLScripter 2.0 ReadMe.
Command Line Syntax:
SQLScripter.exe [/{S|SERVER}=ServerName]
[/{U|USER}=Login]
[/{P|PW|PASSWORD}=Password]
[/{DB|DATABASE}=Database1[,Database2[,n...]]]
[/{DBA|DBAOPTIONS}={ALL|[A][B][D][J][L]}]
[/DEL=NumberOfWeeks]
[/{DIR|DEST|DESTDIR}=d:\path]
[/{BG|BACK|BACKGROUND}]
Command Line Switches:
[/{S|SERVER}=ServerName]
ServerName = Name of the server to script from
[/{U|USER}=Login]
Login = Login to use to connect to the server. Leave empty for trusted connection.
[/{P|PW|PASSWORD}=Password]
Password = Password to use to connect to the server. Leave empty for trusted connection.
[/{DB|DATABASE}=Database1[,Database2[,n...]]]
Database1[,Database2[,n...]]] = Comma-seperated list of databases to script.
[/{DBA|DBAOPTIONS}={ALL|[A][B][D][J][L]}]
ALL = Enable all DBA scripting options.
Or use any combination of the following:
A = Script alerts and operators.
B = Script Backup Devices.
D = Save DTS Packages as Structured Storage Files.
J = Script the SQL-Server Agent jobs.
L = Script the server logins.
[/DEL=NumberOfWeeks]
NumberOfWeeks = Number of weeks to keep old files. Omit to keep all old files.
[/{DIR|DEST|DESTDIR}=d:\path]
d:\path = destination directory for the scripts.
[/{BG|BACK|BACKGROUND}]
Run in the background without a GUI. SQLScripter will do this automatically whenever
you provide the server, destination dir and database command-line switches. Use the
BACKGROUND switch if you only need to script server objects and don't need to provide
a list of databases to script.
All parameters are optional.
- When the /BACKGROUND switch is specified, the program will start scripting unattended - provided
that the servername and destination directory switches are specified.
- When the /SERVER, /DATABASE and /DESTDIR parameters are all specified the program will also
run unattended.
- When neither of the above two points are true, the program will fire up the GUI with the on the
command line specified parameters already filled in.
GUI operation:
After starting up the program, select a server from the list or enter the server name if it's
not in the list and choose an authentication mode (fill in the login and password fields if
you're using SQL Server authenticaton). Click the "Connect & Fetch Databases" button. Now select
the databases you want to script objects from, enter or select a destination directory and decide
if you want to program to delete old files for you. Go to the Options tab and select all the
types of objects you want to generate scripts for. Once all your choices are made, click the
Generate button and the program will start generating scripts, showing you a log of its current
activity.
Once you're done you can go back to the Scripting tab and select another server to script
objects from. If you need to log on to the same server using other login credentials, you'll
have to click the Disconnect button first, and "Connect & Fetch Databases" again after you've
changed the login and password fields.
At any time you can click the Save Log button to save the log file of your operations so far
and click Clear Log button to start a new log with a clean slate.
Examples:
SQLScripter.exe /S=MyServer /U=MyLogin /P=MyPassword
Starts up the GUI, logs in to MyServer using the MyLogin SQL Server login with password
MyPassword and fetches the list of available databases.
SQLScripter.exe /S=MyServer /DB=MyDatabase,pubs,Northwind /DIR=C:\Windows\Temp
Scripts the MyDatabase, pubs and Northwind databases from server MyServer to the
C:\Windows\Temp directory, using a trusted (NT) connection. All existing files
in this directory will be kept. All this is done unattended.
SQLScripter.exe /SERVER=MyServer /DATABASE=MyDatabase,pubs,Northwind /DESTDIR=C:\Windows\Temp
/USER=MyLogin /PASSWORD=mypassword /DBA=dj /DEL=2
Scripts the MyDatabase, pubs and Northwind databases from server MyServer to the
C:\Windows\Temp directory, as well as all the DTS Packages and Agent jobs, using
'MyLogin' with password 'mypassword' to connect to the server. All existing files
in C:\Windows\Temp that are older then 2 weeks will be deleted. All this is done
unattended.
SQLScripter.exe /s=MyServer /dba=all /dir=C:\Windows\Temp /bg
Scripts all Alerts, Operators, Backup devices, SQL Server Agent Jobs and Server Logins.
Also saves the DTS Packages as structured storage files, but does not script any database
objects. All this is done unattended.
Note: Only sysadmins can save/script "server-objects" (DTS Packages, operators/alerts, Agent jobs and
logins). I would have liked to include the possibility for developers to save their own DTS packages
using their own login, but due to the various unpredictable quirks of the DTS designer this almost
seems impossible to accomplish (at least when using mixed security mode).
To see what I mean, log into your client station using an NT login that has access to the
server, and then log in to the SQL Server from that station using an SQL Server login. Create a DTS
package and save it to the server. Now look at the owner column in msdb..sysdtspackages. This will
contain "DOMAIN\USER" (the NT login) instead of the SQL Server login you created the package with.
Neat eh? To make it better, look at the owner column of a package created while logged in using NT
authentication. Instead of the expected "DOMAIN\USER" value, you'll only find "USER" there!? Now tell
me, are these packages owned by different users, or the same one? If anyone has any tips/workarounds
considering this problem, please let me know.
Visual Basic Version: 6.0 (Tested with VB6.0 SP4 and SP5)
Libraries used by the program:
- Microsoft SQLDMO Object Library (Tested with MS SQL 7.0 SP2 DLLs)
- Microsoft DTSPackage Object Library (Tested with MS SQL 7.0 SP2 DLLs)
Components used by the program:
- Microsoft Windows Common Controls 6.0 (Tested with VB6.0 SP4 and SP5 OCX)
Changes since version 1.0:
- Corrected a bug in scripting the UDTs (which weren't scripted at all in 1.0).
- Included scripting of Backup Devices.
- Eliminated the use of ADO libraries.
- Some minor additions to the log-messages.
- Tried to include an option for non-sysadmins to save their own DTS Packages, but got so annoyed with
the inconsistencies in sysdtspackages (notably the owner column) that I gave up on it.
Use this program and code at your own risk! You can use parts or all of this code in your own
applications if you really want to. I would appreciate it if you can let me know about any bugs you
find, so that if I find the time I can update my own code with your improvements :)
Jeremy van Dijk
j.van.dijk@rvbh.nl
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -