:
declare @EmriServerit varchar(2000)
set @EmriServerit=(select @@servername)
declare @dbname varchar(2000)
set @dbname ='Test1'
declare @Dir varchar(2000)
set @Dir='F:\dataclient.sql'
declare @Command varchar(500)
set @command='osql -E -S ' + @EmriServerit+ ' -d ' +
@dbname +' -i ' + @Dir
exec master.dbo.xp_cmdshell @command
you had a server name declared and used in different ways, and you are not allowed to have expressions as parameters of the stored procedure, so combine the command into a variable and then pass it to the stored procedure master.dbo.xp_cmdshell.
source
share