SQLDMO - Using a Trusted Connection

Posted on 2005-05-04
Last Modified: 2008-02-26

One of the experts here (arbert) sent me a link to a SQL script that scripts out all the objects in a database.  Since we use trusted connections can anyone show me how to modify the script?

-- prepare scripting object
SELECT @context = 'anywhere'
EXEC @rc = sp_OACreate 'SQLDMO.SQLServer', @objServer OUT
IF @rc <> 0 or @@error <> 0 goto ErrorHnd

EXEC @rc = sp_OAMethod @objServer , 'Connect', NULL, @SourceSVR , @SourceUID , @SourcePWD
IF @rc <> 0 or @@error <> 0 goto ErrorHnd
(@rc is returning a value of  *  at this point)

Here's the link for the complete script:


Question by:FoxProMari
    LVL 28

    Accepted Solution

    Try this:

    exec @rc = sp_OASetProperty @objServer, 'loginsecure', 'true'
    IF @rc <> 0 or @@error <> 0 goto ErrorHnd

    exec @rc = sp_OAMethod @objServer , 'Connect', NULL
    IF @rc <> 0 or @@error <> 0 goto ErrorHnd

    Author Comment

    That worked, thanks so much :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now