November 20, 2008 at 3:02 am
Hi all,
I need to find out the size of selected rows in a table of Sql server 2005.
ANyone is having the solution , please help
Thanks in Advance
Jishar
November 21, 2008 at 11:37 am
What are you trying to figure out? The number of bytes required to store the selected data? Is this an audit of some type? There are queries that you can write based on the column type and the length of values within variable column, but that may or may not help you out...
November 21, 2008 at 11:47 am
jishar (11/20/2008)
Hi all,I need to find out the size of selected rows in a table of Sql server 2005.
ANyone is having the solution , please help
Thanks in Advance
Jishar
You can use LEN(column_name)
November 22, 2008 at 12:04 am
Hi,
Thanks for the reply..
i need to find the size utilized on OS by the data in a specific table.
Regards,
Jishar
November 22, 2008 at 12:06 am
[font="Times New Roman"][font="Verdana"]Hi,
Thanks for the reply..
i need to find the size utilized on OS by the data in a specific table.
Regards,
Jishar [/font][/font]
November 22, 2008 at 11:02 am
jishar (11/22/2008)
Hi,Thanks for the reply..
i need to find the size utilized on OS by the data in a specific table.
Regards,
Jishar
So are you looking for table size in the database? or database file size in the OS? Pls clarify.
November 22, 2008 at 3:11 pm
first you said row size, then you said table size...which is it?
there is a difference between the max space that a row can take, and the actual length of any specific row;
you can alos find the max actual size of a row, which would be less than what my query below gives you:
create table ##tmp (TableName varchar(40),DefinedRowSize int)
sp_msforeachtable 'INSERT INTO ##TMP Select ''?'' As TableName, SUM(C.Length) as Length from dbo.SysColumns C where C.id = object_id(''?'') '
select * from ##tmp order by DefinedRowSize desc
Lowell
November 22, 2008 at 3:23 pm
This script will tell you the size of every table in a database.
Script to analyze table space usage
November 22, 2008 at 3:44 pm
You don't need to write anything to get what you want. Just run the following and some of the things it returns are things like Min, Max, and Average row sizes...
[font="Courier New"]DBCC SHOWCONTIG WITH TABLERESULTS[/font]
--Jeff Moden
Change is inevitable... Change for the better is not.
November 22, 2008 at 10:04 pm
[font="Verdana"]Hi,
Thank u for ur reply
I need to find out the Row size
Below is the Scenario,
1. I have one table A with 200000 Rows
2. Retrieveing 75000 rows from A table with certain filter crietaria
3. I want to find out the size of this 75000 Rows
Regards,
Jishar[/font]
November 22, 2008 at 11:47 pm
Why? What purpose are you trying to get that information for?
If you don't need it exact, query sys.dm_db_index_physical_stats for that table, use the detailed option, check the avg_record_size_in_bytes column and multiply that by 75000. That'll give you the aproximate size in bytes of those rows.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 23, 2008 at 6:30 am
3. I want to find out the size of this 75000 Rows
You can dump that 75000 rows in another table and get size of that table, that would be the size of 75000 rows. Now if you want individual size of each row then that would be different story.
November 23, 2008 at 6:59 am
I agree with Gail... you need to tell us "Why" you want/need to do this to make sure we give you the best solution.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 29, 2009 at 12:11 pm
hi, would that be the column Average Record Size? in
DBCC SHOWCONTIG WITH TABLERESULTS
I need to find the average size of a columm in my table to be able to get the average capacity needed if the table keeps growing and I don't find the column Average Row Size in the results.
October 30, 2009 at 8:48 am
Following is one way to identifiy the filtered rows size any any given table.
Following is a SSMS Template. Paste following to a SSMS query window and press Ctrl+Shift+M. Specify the database name and Table name. Click ok and in the resultant query specifiy the where clause if you want to limit the rows.
USE <DatabaseName, sysname, AdventureWorks>
declare @sql varchar(max), @TableName varchar(500), @DbName varchar(100)
Select @DbName='<DatabaseName, sysname, AdventureWorks>',@TableName = '<TableName, sysname, DatabaseLog>'
Select @sql=isnull(@sql+'+','Select @trsf'+@TableName+'=isnull(sum(')+'isnull(DATALENGTH('+Column_Name+'),0)' from Information_Schema.Columns where table_name = @TableName
from '+@DbName+'.dbo.'+@TableName +' with (nolock) --where '
print '--Table:'+@TableName
print 'DECLARE @trsf'+@TableName+' int;'
print @sql
print 'Select @trsf'+@TableName +' [@trsf'+@TableName+']
'
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply