how to perform a requet that uses two different data base

  • Good morning

    I've requet this:

    declare @ D VarChar (20)

    exec dbo.sp_IDCode'001 ',' ACE ', @ D output

    Select D @

    on the basis donneé TOPIC

    and I know if I put it in the given base POTIC

    like this:

    declare @ D VarChar (20)

    exec dbo.sp_IDCode'001 ',' ACE ', @ D output

    select @ D, name, culeted, vo_id

    from POTIC

    thank you

  • both the French and the English questions left me puzzled... I answered the French one

  • Please don't cross post things. We see all the forums.

    Once you have called the stored procedure, the output parameter comes out in @d and you can use that in a select as you've done.

    select @d, col1, col2

    from othertable.

  • but how there is 2 data base in SQl SERVER 2005 once TOPIC and other POTIC

    give me exemple

  • There can be any number of databases in sqlserver.

    You have 4 system databases:

    -master

    -msdb

    -model

    -tempdb

    (you can have some more in a distribution context)

    All other databases are user databases.

    So you need to connect on one databases like

    use mydb1

    go

    select col1, theothercolumn, ... from theschema.thetable where ...

    go

    or you can directly adress a table in a database using the database name in the select statement.

    select col1, theothercolumn, ... from mydb1.theschema.thetable where ...

    go

    Each db has its own objects, files, filegroups, transaction log(s),...

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply