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
 How can i access one database to another database

Author  Topic 

boreddy
Posting Yak Master

172 Posts

Posted - 2008-08-07 : 02:35:58
I have Script
now i connected to DB1 database
from this database i need to execute that script to DB2 database(another database)

how it possible
please help me

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-07 : 02:40:27
are they in same server? if yes you can execute. you just need to specify qualifier DB2. for all objects.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-07 : 02:41:24
select column from database.schema.tablename

Webfred
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-07 : 02:42:13
again - too late
Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-08-07 : 02:46:16
if the database is in same server
select col1,col2 from database_name..table_name

if the database is in some other server use linked server concept
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-07 : 02:50:18
select parrot from zoo.avian.cage
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-07 : 02:53:23
quote:
Originally posted by webfred

again - too late


Go to Top of Page

boreddy
Posting Yak Master

172 Posts

Posted - 2008-08-07 : 03:00:02
if it is tbale i can apply ur suggestion

here my script is very big and i used many system tables,systemviews and join and temp table
it not possible
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-07 : 03:34:15
quote:
Originally posted by boreddy

if it is tbale i can apply ur suggestion

here my script is very big and i used many system tables,systemviews and join and temp table
it not possible


Why are trying to run it from other db in first place?
Go to Top of Page

boreddy
Posting Yak Master

172 Posts

Posted - 2008-08-07 : 03:52:23
Here requirement is like this

end user will connect to server and
they will give database name,by useing this database
i shoul have to get the tables,column,constraints,column datatype
in given formate
here i wrote the code to get all above requirements
where i run this this cript i am getting that database related information
i am not able to get the user given database information
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-07 : 13:25:02
Show us what you have tried.
Go to Top of Page
   

- Advertisement -