1 . How can i get a Database Size by means of a SQL query?
2. How can i Get a field size (not allocated space) .. ie. i am
storing some textual data to a field..
after a insertion i want to know how much space has been occupied by
that particular field .
ex sno product_name Description
1 sample1 dfkjsdkfj kldsjfkdjk
sdkjdfskdjk vcmvxcvmcvnksdjfkdsn m
Here i want know the space occupied by the field name "description"
for the product id=1.
Thanks in adavance
Regards
Visu.On Jun 12, 12:35 pm, visu <k.vis...@.gmail.comwrote:
Quote:
Originally Posted by
I want to know following memory space related question.
>
1 . How can i get a Database Size by means of a SQL query?
>
2. How can i Get a field size (not allocated space) .. ie. i am
storing some textual data to a field..
after a insertion i want to know how much space has been occupied by
that particular field .
>
ex sno product_name Description
1 sample1 dfkjsdkfj kldsjfkdjk
sdkjdfskdjk vcmvxcvmcvnksdjfkdsn m
>
Here i want know the space occupied by the field name "description"
for the product id=1.
>
Thanks in adavance
>
Regards
Visu.
1. How can i get a Database Size by means of a SQL query
sp_helpdb 'dbname'
2. Here i want know the space occupied by the field name "description"
for the product id=1.
SELECT SUM(DATALENGTH(description)) FROM table
WHERE product_id=1.|||On Jun 12, 10:47 am, M A Srinivas <masri...@.gmail.comwrote:
Quote:
Originally Posted by
On Jun 12, 12:35 pm, visu <k.vis...@.gmail.comwrote:
>
>
>
>
>
Quote:
Originally Posted by
I want to know following memory space related question.
>
Quote:
Originally Posted by
1 . How can i get a Database Size by means of a SQL query?
>
Quote:
Originally Posted by
2. How can i Get a field size (not allocated space) .. ie. i am
storing some textual data to a field..
after a insertion i want to know how much space has been occupied by
that particular field .
>
Quote:
Originally Posted by
ex sno product_name Description
1 sample1 dfkjsdkfj kldsjfkdjk
sdkjdfskdjk vcmvxcvmcvnksdjfkdsn m
>
Quote:
Originally Posted by
Here i want know the space occupied by the field name "description"
for the product id=1.
>
Quote:
Originally Posted by
Thanks in adavance
>
Quote:
Originally Posted by
Regards
Visu.
>
1. How can i get a Database Size by means of a SQL query
>
sp_helpdb 'dbname'
>
2. Here i want know the space occupied by the field name "description"
for the product id=1.
>
SELECT SUM(DATALENGTH(description)) FROM table
WHERE product_id=1.- Hide quoted text -
>
- Show quoted text -
Use the length function
SELECT LENGTH(description) FROM tablename WHERE id = 1
This will return the length of the description field for the row
identified by id = 1.|||undercups (dwang@.woodace.co.uk) writes:
Quote:
Originally Posted by
Use the length function
>
SELECT LENGTH(description) FROM tablename WHERE id = 1
>
This will return the length of the description field for the row
identified by id = 1.
There is no LENGTH function in SQL Server.
You may be thinking of len(), but since Visu asked for the space
consumption, it does not fit the bill for two reasons:
1) It ignores trailing spaces.
2) It counts characters, not bytes, which makes a difference for nvarchar.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||M A Srinivas (masri999@.gmail.com) writes:
Quote:
Originally Posted by
2. Here i want know the space occupied by the field name "description"
for the product id=1.
>
SELECT SUM(DATALENGTH(description)) FROM table
WHERE product_id=1.
Should be:
SELECT SUM(2 + DATALENGTH(description)) FROM table
WHERE product_id=1.
Add 2 for the length stored for the field.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
No comments:
Post a Comment