[Webinar] Learn how to a build a cloud-first strategyRegister Now


SQLDMO - Using a Trusted Connection

Posted on 2005-05-04
Medium Priority
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:Mariyam
LVL 28

Accepted Solution

rafrancisco earned 1400 total points
ID: 13931240
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

ID: 13932127
That worked, thanks so much :-)

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

864 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