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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 run script

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2009-05-14 : 08:51:38
Hi,
I am running a query as below.

It runs a script against the specified NetworkSQLServername.

Problem: The system does not run the script against the specified @NetworkSQLServername because it seems to run it against the machine where you are running it from.
Do you see anything wrong for the parameter of @NetworkSQLServername ?

Thanks

declare @SQLscript varchar(1000)

select @NetworkSQLServername = NetworkSQLServername
from tableName

set @SQLscript = 'osql -ES' + ltrim(rtrim(@NetworkSQLServername)) + ' -dmaster -i"\\localmachine\c$\Temp\DB_Team\SQL\script.sql" -o"\\localmachine\c$\Temp\DB_Team\SQL\logfile.txt"'

exec master..xp_cmdshell @SQLscript
   

- Advertisement -