Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Exec storedprocedure results don't have header info?

$
0
0

I have requirement to send the weekly database size (day by day size) in the form of email attachment?

i created sp with below :

GO
ALTER procedure [dbo].[GETDBSIZEWeeklyReport]
as
set nocount on 

select
database_name,
--msdb.dbo.backupset.backup_start_date as StartDate,  
   --msdb.dbo.backupset.backup_finish_date as EndDate,
--BackupDate = DATEADD(day,-7, GETDATE())
SizeInGigs=( backup_size/1024000000)
from msdb..backupset
where
(CONVERT(datetime, msdb.dbo.backupset.backup_start_date, 102) >= GETDATE() - 7) 
order by database_name, backup_start_date desc

And running below :

EXEC xp_cmdshell 'bcp "exec msdb.dbo.getdbsizeweeklyreport" queryout "D:\DBA\bcptest.txt" -T -c -t,'

Results :

PM,7.45998900000
PM,7.45998900000
PM,7.44360500000
PM,7.44360500000
master,.00308400000
master,.00308400000
master,.00308400000
master,.00308400000
model,.00135500000
model,.00135500000
model,.00135500000
model,.00135500000
msdb,.01647700000
msdb,.01647700000
msdb,.01647700000
msdb,.01647700000
CC,.03182500000
CC,.03182500000
CC,.03182500000
CC,.03284900000

How can format them and get the headers on top them like db name and size?

Thanks,

Ron.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>