Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sp_OAMethod -- changing to windows authentication from sql

Status
Not open for further replies.

vadimg

IS-IT--Management
Oct 25, 2001
152
0
0
US
hi. Here's the code that gets executed to script objects. I've always used sql authentication for sp_OAMethod, but i'd like to change that to windows authentication...
Does anyone know how to code sp_OAMethod to use local windows account?

Thanks!!

Code:
DECLARE @object int, @hr int, @return varchar(255)
exec @hr = sp_OACreate 'SQLDMO.SQLServer', @object output
[COLOR=red][b]exec sp_OAMethod @object, 'Connect', NULL, 'localhost', 'sa', 'password' [/b][/color]
exec sp_OAGetProperty @object, 'Databases("DBName").Tables("table_name").Script(1023,"C:\path\table_name.table","",16)', @return output
exec sp_OADestroy @object
 
if anyone is interested -- here's the solution i found -- i forgot to set LoginSecure property...
so the correct code would look like this:
Code:
DECLARE @object int, @hr int, @return varchar(255)
exec @hr = sp_OACreate 'SQLDMO.SQLServer', @object output
[COLOR=red][b]exec @hr = sp_OASetProperty @object, 'LoginSecure', TRUE
exec sp_OAMethod @object, 'Connect', NULL, 'localhost'[/b][/color]
exec sp_OAGetProperty @object, 'Databases("DBName").Tables("table_name").Script(1023,"C:\path\table_name.table","",16)', @return output
exec sp_OADestroy @object
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top