June 6, 2011 at 10:58 am
Hello,
I was wondering if someone could please help me. I created a stored procedure utilizing the SQL
Server Stuff function please refer to code below:
select
'99999' + ',' +
'Hospital' + ',' +
CONVERT(varchar(4), datepart(yy, getdate()))+
right('0' + CONVERT(varchar(2), datepart(mm, getdate())),2)+
right('0' + CONVERT(varchar(2), datepart(dd, getdate())),2)+
right('0' + CONVERT(varchar(2), datepart(hour, getdate())),2)+
right('0' + CONVERT(varchar(2), datepart(minute, getdate())),2)+ ',' +
stuff (( select
cast(sum(case
--when asgn_bed_spa_ts IS null and placement not in ('3','4','6','8','9','10') then 1
when asgn_bed_spa_ts is null and placement in ('1','2','5','7') then 1
else 0
end) as varchar) + ','
FROM @CENSUS_WORK
group by (placement)
for XML PATH('')
),1,0,'') as 'HospitalPFI,HospitalName,Report_Datetime,AdICU,MedSurg,Burn,PedICU,PedMedSurg,Psych,NegPress,ORbeds,Other,Vents'
When I execute my stored procedure via the Query Window I receive the following results:
HospitalPFI,HospitalName,Report_Datetime,AdICU,MedSurg,Burn,PedICU,PedMedSurg,Psych,NegPress,ORbeds,Other,Vents
99999,Hospital,201106061229,14,27,0,0,11,0,1,0,0,0,
However when I schedule a job via the Job Agent to execute the stored procedure
Job step contains [exec usp_sp_havabed] output to a filename.
I receive the following results.
Can someone please help me to understand why I am not receiving any data.
HospitalPFI,HospitalName,Report_Datetime,AdICU,MedSurg,Burn,PedICU,PedMedSurg,Psych,NegPress,ORbeds,Other,Vents
June 6, 2011 at 2:12 pm
We are not able to see over your shoulder nor do any of us have any knowledge of your problem other than what you stated. I can think at least 5-6 things that MIGHT be the problem. However with no details it is impossible to tell. Please look at the link in my signature for best practices on posting a question in such a way as to maximize the possibility of getting a valid response.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 6, 2011 at 5:55 pm
Can you provide how you are calling the proc from the job? It's possibly in how the proc is called.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply