Showing posts with label output. Show all posts
Showing posts with label output. Show all posts

Thursday, March 22, 2012

Database size

Is there any way I can join all the information produced by this into a single output rather than multiple outputs

EXEC sp_MSforeachtable @.command1=" EXEC sp_spaceused '?'"

Like this
Listing_Images 43 16 KB 8 KB 8 KB 0 KB
User 3 16 KB 8 KB 8 KB 0 KB

I want to fill a gridview in ASP but don't know how to deal with data produced through multiple queriesLook at the code of sp_spaceused and build what you need
select name=object_name(i.id)
,rows=sum(case when indid<2 then rows else 0 end)
,reservKB=convert(int,sum(reserved)/.125)
,dataKB=convert(int,sum(case
when indid<2 then dpages
when indid=255 then isnull(used,0)
else 0 end)/.125)
,indexKB=convert(int,(sum(used)-sum(case
when indid<2 then dpages
when indid=255 then isnull(used,0)
else 0 end))/.125)
,unusedKB=convert(int,(sum(reserved)-sum(used))/.125)
from sysindexes i join sysobjects o on i.id=o.id
where indid in (0, 1, 255)
and o.xtype='U'
-- and id in (object_id('Listing_Images'), object_id('User'))
group by i.id

else

create table #t1 (Table_name varchar(128), Records varchar(11)
,reservedKB varchar(18), dataKB varchar(18), index_sizeKB varchar(18)
,unused varchar(18))
insert #t1 exec sp_spaceused Listing_Images
insert #t1 exec sp_spaceused User
select * from #t1
drop table #t1|||I see what you mean, Ive done the same thing at an application level where it executes and inserts each result as a row,

While myReader.Read
Dim newRow As DataRow = dt.NewRow()
newRow("name") = myReader("name").ToString
newRow("rows") = myReader("rows").ToString
newRow("data") = myReader("data").ToString
newRow("index_size") = myReader("index_size").ToString
newRow("reserved") = myReader("reserved").ToString
newRow("unused") = myReader("unused").ToString
dt.Rows.Add(newRow)

Total_IndexSize = Total_IndexSize + Convert.ToInt32(myReader("index_size").ToString().Split(SpaceDelimiter)(0))
Total_DataSize = Total_DataSize + Convert.ToInt32(myReader("data").ToString().Split(SpaceDelimiter)(0))
Total_ReservedSpace = Total_ReservedSpace + Convert.ToInt32(myReader("reserved").ToString().Split(SpaceDelimiter)(0))
Total_UnusedSpace = Total_UnusedSpace + Convert.ToInt32(myReader("unused").ToString().Split(SpaceDelimiter)(0))
End While|||Updated my previous post

Tuesday, February 14, 2012

Database Output Problem for a SQL Server 2000 stored procedure

Hi,

I have a problem with "database output" window in executing a select-sp in vs 2005 standard. The db is a sql server 2000 one.

When I execute the sp within VS, the database output correctly displays the execution information:

No rows affected.
(1 row(s) returned)
@.RETURN_VALUE = 3

but I can't see the returned rows (3 rows are returned); I only see the column names and no data.

Running [dbo].[spBkm_GetList] ( @.IDUser = <DEFAULT>, [.......]).

IDBkm UIBkm IDUser
------- ------------ ---No rows affected.

If I run the same sp in Sql Server Manager Studio Express it correctly shows the data of the 3 rows returned.

The sp uses

EXECsp_executesql @.Sql, @.ParamList, .....

for executing the sql statement and the last line of sp is
RETURN@.@.ROWCOUNT

I've tried removing the "RETURN @.@.ROWCOUNT" with no success.

The problem affects only one sp, the others, which are absolutely similar, work properly .

I don't know what is the problem...

Any idea?

Thanks in advance

Ive' resolved the problem in a strange way, it seems to me a bug...

If I exclude from the select statement a field of type uniqueidentifier, alla data are correctly displayed!

I've tried on other sp and the behaviour is the same.

Hope this may help someone else with the same problem...