August 17, 2012 at 5:24 am
While executing the below query to find the results getting the below error:
Do I need to use cast/convert statement?
Msg 8117, Level 16, State 1, Line 1
Operand data type nvarchar is invalid for sum operator.
select sum(database_name), backup_size/(1024*1024),
backup_finish_date,type from backupset where type ='D'
--order by backup_finish_date asc
group by database_name
Thanks.
August 17, 2012 at 6:07 am
No. Cast/convert will not help here. You need to remove SUM() around database_name.
Evenafter that the query fails.
What are you trying to achieve? Other may help you to rewrite the query.
August 17, 2012 at 6:09 am
Hello,
database_name is a nvarchar, how can you pass it to SUM?
alter the query.
Regards
Durai Nagarajan
August 18, 2012 at 1:20 am
Why do u want to sum database names????? sum is an aggregate function..how can it sum varchar column? what r u trying to achieve?
August 18, 2012 at 1:22 am
I think you are trying to find the combined backup size of all databases..is it?
August 18, 2012 at 2:27 am
... or trying for COUNT(database_name) ...huh ?
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply