Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
SQL Server Newbies
»
Auto-Select Database Name
Auto-Select Database Name
Rate Topic
Display Mode
Topic Options
Author
Message
gillygilligan84
gillygilligan84
Posted Friday, July 04, 2008 8:39 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, September 06, 2011 6:53 AM
Points: 172,
Visits: 45
I have several databases to select from and each time I have to use the drop down menu to select the database I need. Is there any way of declaring which database I want to use without using the drop down menu?
Post #528693
KenSimmons
KenSimmons
Posted Friday, July 04, 2008 8:49 AM
Ten Centuries
Group: General Forum Members
Last Login: Thursday, May 09, 2013 8:07 AM
Points: 1,221,
Visits: 2,614
You can put a use statement in the script.
Use database1
go
Select statment
Use database2
go
Select statement
Ken Simmons
http://twitter.com/KenSimmons
Post #528699
Clive Strong
Clive Strong
Posted Friday, July 04, 2008 10:42 AM
SSC Eights!
Group: General Forum Members
Last Login: Monday, May 13, 2013 10:12 AM
Points: 959,
Visits: 6,341
Just qualify the database in the FROM clause.
SELECT Col1, Col2
FROM TestDB1.dbo.MyTable
SELECT Col5, Col10, Col7
FROM DifferentDB.dbo.AnotherTable
Run the queries and you'll be querying the databases without the need to change the database manually or use the USE syntax.
Post #528726
Carl Federl
Carl Federl
Posted Friday, July 04, 2008 11:25 AM
SSCrazy
Group: General Forum Members
Last Login: 2 days ago @ 3:55 PM
Points: 2,224,
Visits: 4,079
You can also create a shortcut to Query Analyzer that will automatically connect to a specific server and database. The command line is:
isqlw.exe -S
You can also add -E for Integrated Security or "-U -P" to hard code a login and password.
SQL = Scarcely Qualifies as a Language
Post #528738
Carl Federl
Carl Federl
Posted Friday, July 04, 2008 11:27 AM
SSCrazy
Group: General Forum Members
Last Login: 2 days ago @ 3:55 PM
Points: 2,224,
Visits: 4,079
The command line was truncated:
isqlw.exe -S SqlServerName -D DatabaseName
SQL = Scarcely Qualifies as a Language
Post #528739
k man
k man
Posted Friday, February 11, 2011 11:26 AM
SSC Veteran
Group: General Forum Members
Last Login: Friday, September 14, 2012 2:11 PM
Points: 227,
Visits: 133
You can always change your default database to one you use the most...
Post #1062753
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.