Connie (csawyer (AT) rwbaird (DOT) com) writes:
Quote:
If I run it like this select sum(datalength (cast(document AS
varbinary))) from plan_report
I get 89010 this as a result |
Because in this context the default is varbinary(30).
Quote:
If I run this: select datalength(document) from plan_report then I
get a result for each row and when I sum those rows I get 5584452854
this as a result. |
The obvious query would be
SELECT SUM(datalength(document)) FROM plan_report
you don't say whether you tried this, but I can see that it will fail
with integer overflow. Howeever this should work:
SELECT SUM(cast(datalength(document) as bigint)) FROM plan_report
--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx