May 8, 2006 at 3:38 am
Hi All
In a SP how i can find the DB size. Is there any system SP for this purpose?
Regards
Qaiser
May 8, 2006 at 1:29 pm
Check out the below link. I'm not sure if their is or not a system sproc...If it's not listed in sql books online (i'm sure you checked) their probably isn't. The article basically is creating it's own sproc that will get the size of db using dbcc commands.
May 8, 2006 at 9:16 pm
Hi John
Where is link? I think you forget to paste the link.
Regards
Qaiser Javed
May 9, 2006 at 1:17 am
Try the sp_helpdb, sp_helpfile and sp_spaceused system SPs.
May 9, 2006 at 5:58 am
Also try sp_databases
May 9, 2006 at 7:24 am
sp_helpdb could be better when compared with sp_databases
since if database size is more than 2 TB then sp_databases could have
some problems.
May 9, 2006 at 12:33 pm
Sorry I can't find the link i was googling it and can't remember my search criteria. Anyways the answer is as stated before by others is using sp_helpdb or sp_databases.
If you want to have a stored procedure that returns the specific size then you can create your own sproc that that will return your own result sets.
Maybe you can use the INSERT ... EXECUTE command? Something like this:
CREATE TABLE #temp1 (....)
CREATE TABLE #temp2 (....)
INSERT #temp1 (column list)
EXECUTE sp_helpdb
INSERT #temp2 (column list)
EXECUTE sp_databases
SELECT columns you like to see
FROM #temp1
JOIN #temp2
ON your joine criteria
WHERE some optional extra filters
hope this helps...
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply