Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL 2000 query to populate temp table using EXEC sp_spaceused


SQL 2000 query to populate temp table using EXEC sp_spaceused

Author
Message
melloman
melloman
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 31
Hi,

I was wondering if you could help me.

I was wondering how to populate the output of SQL2000 sp_spaceused into a temp table (#t). But my flowing T-SQL query fails:


CREATE TABLE #t
(database_name VARCHAR(20), database_size VARCHAR(18), [unallocated space] VARCHAR(18),
reserved VARCHAR(18),data VARCHAR(18), index_size VARCHAR(18), unused VARCHAR(18)
)

select * from #t
--EXEC sp_spaceused

INSERT INTO #t (database_name, database_size, [unallocated space], reserved, data, index_size,unused) EXEC sp_spaceused
--drop table #t

error mgs on running I get:
Server: Msg 213, Level 16, State 7, Procedure sp_spaceused, Line 148
Insert Error: Column name or number of supplied values does not match table definition.

Can anyone help?
Michael Valentine Jones
Michael Valentine Jones
Hall of Fame
Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)

Group: General Forum Members
Points: 3264 Visits: 11771
This script provides a good example of what you are trying to do.

Script is used to analyze table space usage using the output from the sp_spaceused stored procedure
Works with SQL 7.0, 2000, 2005, 2008, 2008 R2. May work with 2012, but I havn't tested it there.

Script to analyze table space usage
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61762
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search