To answer your second question, you can log into SQL Server from the Windchill shell (or any command prompt) by using SQL Server's built in sqlcmd utility. The syntax to log into SQL Server is:
sqlcmd -S <ServerName> -U <Username> -P <password> -d <databaseName>
To run a script, you can use:
sqlcmd -S <ServerName> -U <Username> -P <password> -d <databaseName> -i <sql script> -o <output file>
If you leave off the -o argument, the script will output its results to the shell.