Login using osql
Windows Auth
osql -E
SQL Auth
osql -U sa
List databases
1>sp_databases
2>go
To list the tables in a database
1>use dbname
2>go
1>sp_tables
2>go
To show the table structure
1>use dbname
2>go
1>sp_help table_name
2>go
Attach a DB
exec sp_attach_db @dbname = 'test3',
@filename1 = 'C:\data\master.mdf',
@filename2 = 'c:\data\mastlog.ldf'
go
Detach a DB
EXEC sp_detach_db 'mydb'
go
0 Comments