How to initiate COM....

  • How we initiate the COM application in stored procedure. Suppose i have a COM server then i want to call function of COM Server so how i can do that ? Please help me...

    Thanks

    Rakesh

    rakesh


    rakesh

  • Have a look at sp_OACreate in BOL.

    You can do anything with COM and sp_OACreate.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Thanks Crispin. I got another doubt Is it possible to query from two different SQL Server if yes can please give me an example ?

    Thanks

    Rakesh

    rakesh


    rakesh

  • If you talking about a proc querying two servers, yes. I would lie to you if I told you how etc. Linked servers is not my strong point. There will be somone else here who could help you.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Hi there

    declare @object int, @hr int

    sp_OACreate is the way to go, along with its associated calls.. eg:

    exec @hr = sp_OACreate 'SimpleCDO.Message', @object OUT

    -- "SimpleCDO" is the DLL, Message is the Class

    -- sendmessage is the method, along with its parameters listed..

    exec @hr = sp_OAMethod @object, 'SendMessage', @v_returnval OUT, @PTO, @PFROM, @PSUBJECT, @PBODY, @serveraddress, @v_returnval

    exec @hr = sp_OADestroy @object

    the OA calls are in the master db.

    Linked servers are the way to go with cross db calls, uses a 4 part naming convention as:

    <linkedservername>.<database>.<owner>.<obj>

    creating the linked server can be tricky at times depending on the source your connecting to but is generally reliable. Search this site for articles related to the topic.

    Cheers

    Ck

    Chris Kempster

    http://www.chriskempster.com

    Author of "SQL Server 2k for the Oracle DBA"


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

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

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