Sometimes it serves a lot of time to just connect to the database using the command prompt, its easy, reliable and fast.
In this section, I will outline how to connect to an instance of SQL server and get access to databases on your local machine:
- Open up a command prompt
- type: sqlcmd
- On the same line, type: -S(ServerName\SqlInstanceName)
- Then you can query: Select * from sys.databases
- On the next line: Type Go
- If successfully connected, all the databases will display
- Then go ahead and choose which database to use by typing:
- Use "your database"
- On the next line:
- If you are using T-sql just to show the tables in that database just type:
- sp_tables "DatabaseName" (without quotation marks)
- On the next line, type 'Go' and enter
- All the tables should display then use the tables you want to query the data. Have fun.
Write an Article