Solved

passing a parameter to system stored procedure

Posted on 2009-05-15
4
188 Views
Last Modified: 2012-05-07
I use the stored procedure
sp_spaceused tablename
to get the space for a table
but i have 135 table in my DB
 select name from sys.tables
, so i need to make a loop for the result set for the previous select , an pass the table name to the SPSpaceused to get space used by each table



select name from sys.tables

Open in new window

0
Comment
Question by:ali_alannah
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24399846
sp_MSForEachTable " sp_SpaceUsed '?' "
0
 

Author Comment

by:ali_alannah
ID: 24399965
Hi aneeshattingal:
i tried your hint ,it worked , but what if i need the result in one resulset?
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24399999
create a temptable with exactly the same structure that the sp_SpaceUsed 'tableName' returns, (Same no of columns and datatype )
then use this

INSERT INTO #Temp
EXEC sp_MSForEachTable " sp_SpaceUsed '?' "
0
 

Author Closing Comment

by:ali_alannah
ID: 31582119
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Encryption question 2 56
SQL Server 2012 express 24 38
Help with simplifying SQL 6 53
SQL Server 2005 - Comparing Fields' Contents 6 35
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question