Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

msdb..backupset : Query Error. Expand / Collapse
Author
Message
Posted Friday, August 17, 2012 5:24 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: 2 days ago @ 3:08 AM
Points: 785, Visits: 1,259
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.
Post #1346476
Posted Friday, August 17, 2012 6:07 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, April 14, 2014 2:19 AM
Points: 1,101, Visits: 5,271
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.
Post #1346496
Posted Friday, August 17, 2012 6:09 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, March 19, 2014 5:48 AM
Points: 1,048, Visits: 2,646
Hello,

database_name is a nvarchar, how can you pass it to SUM?

alter the query.



Regards
Durai Nagarajan
Post #1346497
Posted Saturday, August 18, 2012 1:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 04, 2013 5:44 AM
Points: 5, Visits: 80
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?
Post #1346816
Posted Saturday, August 18, 2012 1:22 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, June 04, 2013 5:44 AM
Points: 5, Visits: 80
I think you are trying to find the combined backup size of all databases..is it?
Post #1346817
Posted Saturday, August 18, 2012 2:27 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 9:50 AM
Points: 1,458, Visits: 2,435
... or trying for COUNT(database_name) ...huh ?
Post #1346826
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse