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
 Store Procedure

Author  Topic 

atuljadhavnetafim
Starting Member

25 Posts

Posted - 2013-11-06 : 04:21:16
Dear Sir

i have database "Northwind", and Table Name "Data"
and in "Data" Table the column as per below

CustomerID
CompanyName
ContactName
OrderID
EmployeeUD
FirstName
LastName
ShippedDate
ProductName
UnitPrice
Quantity

now i have to make store procedure in programmability, and i use below code

CREATE PROCEDURE [dbo].[SP_GetOrdersForCustomer]
@CustomerID nchar(5)
AS
BEGIN
SELECT cst.[CustomerID],
cst.[CompanyName],
cst.[ContactName],
ord.[OrderID],
ord.[EmployeeID],
emp.[FirstName],
emp.[LastName],
ord.[ShippedDate],
prd.[ProductName],
od.[UnitPrice],
od.[Quantity]
FROM [Customers] cst,
[Orders] ord,
[Order Details] od,
[Employees] emp,
[Products] prd
WHERE ord.[CustomerID] = cst.[CustomerID]
AND emp.[EmployeeID] = ord.[EmployeeID]
AND od.[OrderID] = ord.[OrderID]
AND prd.[ProductID] = od.[ProductID]
AND cst.[CustomerID] = @CustomerID
ORDER BY cst.[CustomerID], emp.[EmployeeID], ord.[ShippedDate] DESC
END

but it did not work, it give error

"Msg 208, Level 16, State 1, Procedure SP_GetOrdersForCustomer, Line 5
Invalid object name 'Customers'."

Please Help


Atul Jadhav

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-06 : 04:34:26
do you've table Customers in the database?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

atuljadhavnetafim
Starting Member

25 Posts

Posted - 2013-11-06 : 04:42:02
no, i don't have

i have simple dealer wise Sales report and want to get data from that table only

Atul Jadhav
Go to Top of Page

atuljadhavnetafim
Starting Member

25 Posts

Posted - 2013-11-06 : 04:59:30
Please give me code to get data from this table only,
i have more then 5lk data, and want to export only from customerID i.e. dealer code

Atul Jadhav
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-06 : 05:08:13
quote:
Originally posted by atuljadhavnetafim

no, i don't have

i have simple dealer wise Sales report and want to get data from that table only

Atul Jadhav


What does that mean?
Which table you want data from? I'm not getting your actual requirement
Unless you've the table Customers you wont be able to get details from it.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

atuljadhavnetafim
Starting Member

25 Posts

Posted - 2013-11-06 : 05:24:30
okey, i explain you

i have Dealer wise sales from last 3 Years day wise,
and that is more then 5lk row item, if i store in my local folder it will be very heavy file, os i store my table in SQL Server, and now i have macro (in local file) which will Call Store procedure in SQL server and that data will show in my local file, but in that my basie store procedure not wokring and i have downloded this code from net.
in my table having all the data no need to depend to another file/table

just to run single dealer data in SQL and that data will show in my local file but to show in local excel file that is second step, my store procedure enven not working in SQL query, so i am worry

i home i explain now well

Atul Jadhav
Go to Top of Page
   

- Advertisement -