SQLDMO - Using a Trusted Connection

Hello,

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:
http://www.nigelrivett.net/DMO/DMOScripting.html

TIA.
--Mari

MariyamAsked:
Who is Participating?
 
rafranciscoConnect With a Mentor Commented:
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
0
 
MariyamAuthor Commented:
That worked, thanks so much :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.