I want to dump results of my stored proc to a file, save it somewhere or call it from ASP.Net and display the results. I found an example: declare @db1 as varchar(100) declare @db2 as varchar(100) declare @cmd as varchar(500) set @db1='VQUEDTA001' set @db2='VQUEDTA500' Set @cmd= 'osql.exe -S servername -U UID -P PWD -Q "EXEC usp_comparedb ''VQUEDTA001'', ''VQUEDTA500'' " -o "hutput3.txt"' First , I couldnt get the @db1 and @db2 used paramters and ended up hardcoding them. How can I use the variables in there? Second, is there a better way of doing this? another example?