Solved

passing a parameter to system stored procedure

Posted on 2009-05-15
4
171 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

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…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now