Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Variables and the use clause

Author  Topic 

vlfoley
Starting Member

6 Posts

Posted - 2011-05-31 : 12:54:18
i am going to run a simple query to count active users in a database. thie results of this query are going to be stored in another database table. i need to use the 'use' clause in order to make this completely automatic and switch between available databases. i have no clue how to write the insert and update statements to bring the info into the table to save it or how to use the 'use' cluase. any ideas?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-05-31 : 12:57:04
Why do you need to switch between databases?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-06-01 : 00:13:06
try using linked server...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-01 : 00:17:43
A linked server does not help with this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-06-01 : 00:25:19
quote:
Originally posted by tkizer

A linked server does not help with this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



thanks for your valuable reply tara...
may i know the reason..please
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-01 : 01:03:19
Because it is not related to this problem. A linked server is used to access remote servers. That has no bearing with this topic.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

vlfoley
Starting Member

6 Posts

Posted - 2011-06-01 : 07:43:18
We have a seperate database for each client and I need to count the users for each client. The databases are on different servers, not a seperate server for each database but several databases lumped together on one server. 10 databases on a server, 10 on another, like that.
Go to Top of Page
   

- Advertisement -