Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 sp results to table - compile error

Author  Topic 

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-06-28 : 14:21:25

Server: Msg 121, Level 15, State 1, Line 17
The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns.


DECLARE @table_names table(name sysname)
DECLARE @Name as sysname
DECLARE @sql as nvarchar(1000)
Create table #Space_Used
(
Name nvarchar(20), -- Name of the table for which space usage information was requested.
Rows char(11), -- Number of rows existing in the objname table.
reserved varchar(18), -- Amount of total reserved space for objname.
Data varchar(18), -- Amount of space used by data in objname.
index_size varchar(18), -- Amount of space used by the index in objname.
Unused varchar(18) --Amount of unused space in objname.
)
insert into @table_names (name)
select name, * from sysobjects where xtype = 'U'

While exists(Select * from @table_names)
BEGIN
select Top 1 @name = name from @table_names
delete from @table_names where name = @name

INSERT #Space_Used --(Name, Rows, reserved, Data, index_size, Unused)
EXEC sp_spaceused @objname = @name

END


SELECT * FROM #Space_Used
DROP TABLE #Space_Used




You can do anything at www.zombo.com

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-06-28 : 14:22:51
Found it
select name, * from sysobjects where xtype = 'U'

MY BAD!

You can do anything at www.zombo.com
Go to Top of Page
   

- Advertisement -