Written by James McDonald

November 3, 2008

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

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…