Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 osql utility

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2010-03-03 : 17:08:48
Whether osql command can be executed dynamically?

Some thing like below:
[code]
Declare @a nvarchar(100)

Set @a=’sp_who2’

Set @result=’osql –o ’+ @a

(ie) exec (@result)
[\code]

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-03 : 18:24:38
Yes you can do it dynamically, but you have to call osql.exe from xp_cmdshell.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2010-03-04 : 09:37:10
xp_cmdshell can be used only by administrator..if suppose normal user
who dont have the permission of executing xp_cmdshell,then how it can be done?
quote:
Originally posted by tkizer

Yes you can do it dynamically, but you have to call osql.exe from xp_cmdshell.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."

Go to Top of Page
   

- Advertisement -