Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error trying to execute SQL command

Author  Topic 

skriver
Starting Member

11 Posts

Posted - 2012-04-26 : 15:21:37
Hi

Trying to execute this command

select os.OrderedProductSKU, convert(DECIMAL(15,2),SUM(os.OrderedProductPrice)) totalsales
from Orders_ShoppingCart os
join Orders o on o.OrderNumber = os.OrderNumber
where o.OrderDate between '01-Jan-2011' and '01-Jan-2012'
group by os.OrderedProductSKU
order by 2 desc

but I get this error

Msg 208, Level 16, State 1, Line 1
Invalid object name 'Orders_ShoppingCart'.

That is the correct name of the SQL table. Any ideas where its going wrong?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-26 : 15:23:35
Are you executing it in correct database?

Add

USE [yourdbname]
GO

before the select statement and try executing the batch again

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

skriver
Starting Member

11 Posts

Posted - 2012-04-26 : 15:28:33
Perfect!
Go to Top of Page
   

- Advertisement -