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.
Author |
Topic |
Seanryan
Starting Member
16 Posts |
Posted - 2011-10-27 : 05:51:59
|
I have a stored procedure that runs fine as a scheduled agent task and generates a file each night (output file in advanced step for tsql task) but the file is a straight forward space delimited sql output.I have read that osql.exe can be used with - options to create a comma delimited output for SQL.Seems to work but I need to run the stored procedure with @dates and @name prompts of values. Osql.exe doesn't seem to like the use of @name = 'myname" string values?worked it out - just syntax issue. thanks |
|
Seanryan
Starting Member
16 Posts |
Posted - 2011-10-27 : 06:01:25
|
This works as straight execution:declare @st_dat datetimedeclare @en_dat datetimedeclare @shipping_line nchar(30)set @st_dat = dateadd(hour, -23, getdate()) set @en_dat = getdate() exec wct_cms_live.dbo.sp_rep_gatehouse@st_dat = @st_dat,@en_dat = @en_dat,@shipping_line = DFDSContainerLinebut if I call it as:EXEC master..xp_cmdshell 'osql.exe -S WCTMS01 -E -Q "declare @st_dat datetimedeclare @en_dat datetimedeclare @shipping_line nchar(30)set @st_dat = dateadd(hour, -23, getdate()) set @en_dat = getdate() exec wct_cms_live.dbo.sp_rep_gatehouse@st_dat = @st_dat,@en_dat = @en_dat,@shipping_line = DFDSContainerLine" 'I get no rows - I'm presuming the dates are getting messed up |
 |
|
|
|
|