473,473 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to convert this sql statement to storeproc?

1 New Member
How to convert this sql statement to storeproc?
Expand|Select|Wrap|Line Numbers
  1. select    "Dly_DC_LostSlsSnpsht_v"."PlntCd" "Plnt_Id_Cd" , "Dly_DC_LostSlsSnpsht_v"."DivCd" "Div_Cd" ,
  2.         "GlblCatSum"."GlblCatSumCd" "Gbl_Cat_Sum_Cd" , (coalesce("GlblCatSum"."GlblCatSumDesc",
  3.         'Unknow')) "Gbl_Cat_Sum_Desc" , "Dly_DC_LostSlsSnpsht_v"."ProdtCd" "Prod_Cd" ,
  4.         "ProdtGPI"."ProdtLglLongNm" "Matl_Nm" , "Dly_DC_LostSlsSnpsht_v"."WhlslPrcAmt_USD" "Whlsl_Prc__USD_" ,
  5.         sum("Dly_DC_LostSlsSnpsht_v"."EstdLostSlsQty") "Estd_Lost_Sales_Qty" ,
  6.         sum("Dly_DC_LostSlsSnpsht_v"."EstdLostSlsAmt") "Estd_Lost_Sales_Amt" ,
  7.         sum("Dly_DC_LostSlsSnpsht_v"."EstdDmndQty") "Tot_AO_Dmd_Qty" ,
  8.         (sum("Dly_DC_LostSlsSnpsht_v"."EstdLostSlsQty") * 1.0e0) / (NULLIF(sum("Dly_DC_LostSlsSnpsht_v"."EstdDmndQty"),
  9.         0)) "Estd_Lost_Sales__" 
  10.  from "EIS"."Dly_DC_LostSlsSnpsht_v" "Dly_DC_LostSlsSnpsht_v",
  11.         "EIS"."GlblCatSum" "GlblCatSum", "EIS"."ProdtGPI" "ProdtGPI",
  12.         "EIS"."GlblCatCoreFcs" "GlblCatCoreFcs"
  13.  where "Dly_DC_LostSlsSnpsht_v"."CalRunDt" between date - 1 
  14.     and    date 
  15.     and    "Dly_DC_LostSlsSnpsht_v"."ProdtCd" = "ProdtGPI"."ProdtCd" 
  16.     and    "GlblCatCoreFcs"."GlblCatCoreFcsCd" = "ProdtGPI"."GlblCatCoreFcsCd" 
  17.     and    "GlblCatSum"."GlblCatSumCd" = "GlblCatCoreFcs"."GlblCatSumCd"
  18.  group by "Dly_DC_LostSlsSnpsht_v"."PlntCd", "Dly_DC_LostSlsSnpsht_v"."DivCd", "GlblCatSum"."GlblCatSumCd", (coalesce("GlblCatSum"."GlblCatSumDesc", 'Unknow')), "Dly_DC_LostSlsSnpsht_v"."ProdtCd", "ProdtGPI"."ProdtLglLongNm", "Dly_DC_LostSlsSnpsht_v"."WhlslPrcAmt_USD"
Oct 27 '14 #1
1 1260
Frinavale
9,735 Recognized Expert Moderator Expert
Use the CREATE PROCEDURE to create a stored procedure with a name and parameters. Add the SQL command that you posted within the procedure...

For more information about how to create a stored procedure checkout this MSDN Documentation on the CREATE PROCEDURE (Transact-SQL), and this overview on how to Create a Stored Procedure and this documentation on how to Execute a Stored Procedure.

-Frinny
Oct 27 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Service Tech | last post by:
I have a variable that I am passing to a stored procedure from a propritery software application. The variable it passes is the number of days that have passed since 1/1/1900. I cannot seem to...
5
by: Rachel Weeden | last post by:
I'm working on an ASP Web application, and am having syntax issues in a WHERE statement I'm trying to write that uses the CInt Function on a field. Basically, I want to select records using...
11
by: jguilford | last post by:
I have created a SQL Stored Procedure that uses a Case statement to determine the Order By. For one of the Case statements I am trying to turn a Char field into Datetime in for the Order By,...
6
by: Twobridge | last post by:
I hope someone can help me out with my problem. I have found a sql statement that basically pulls all bills filed within a certain time period and the payments made on those bills with in the...
1
by: sp | last post by:
I have this strange problem. The application I am working on imports color values from Flash that look like this: 0x-f9fff6 And, on the script side, it uses a conversion algorithm to convert...
4
by: lyle777 | last post by:
I am having trouble with the nested if statement. can anyone tell me where i went wrong with this code? the syntax error starts by the else statement within the target of the first if statement....
1
by: vasanth chandrasekaran | last post by:
The error is :Syntax error in INSERT INTO statement. This is my code: try { DataSet ds1; OleDbConnection ConnSql; OleDbConnection...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.