|
-
May 6th, 2008, 06:06 AM
#1
Thread Starter
Hyperactive Member
What problem of my store procedure ?
What problem of my store procedure ? can anyone help me to solve my problem thanks a lot.
------------------------------------------------------------
sql Code:
USE [Local Mattress System]
GO
/****** Object: StoredProcedure [WANSERN\wansern].[SP_LoadProduct] Script Date: 05/06/2008 15:18:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Chia Chet Shian
-- Create date: 06/05/2008
-- Description: Load Spec Product
-- =============================================
ALTER PROCEDURE [WANSERN\wansern].[SP_CreateViewProd]
-- Add the parameters for the stored procedure here
@PCRefNo varchar(50),
@ProductCode varchar(50),
@Company_Name varchar(100),
@Brand varchar(250),
@Model varchar(250),
@Prod_Type varchar(50)
AS
if OBJECT_ID(N'View_ProdList',N'V')IS NOT NULL
DROP VIEW VIEW_ProdList
GO
CREATE VIEW View_ProdList AS
SELECT Prod_List.PCRefNo, Prod_List.Product_Code, Prod_List.Company_Name, Prod_List.Brand, Prod_List.Model, Prod_List.Prod_Type,Prod_List.Thinkness, Prod_List.T_Unit, Prod_List.Width, Prod_List.W_Unit, Prod_List.Length, Prod_List.L_Unit, Prod_List.Status, Prod_List.Cost
FROM Prod_List
WHERE Prod_List.PCRefNo = @PCRefNo AND Prod_List.Product_Code LIKE %@ProductCode% AND Prod_List.Company_Name LIKE %@Company_Name% AND Prod_List.Brand = %@Brand% AND Prod_List.Model = %@Model% AND Prod_List.Prod_Type LIKE %@Prod_Type%
GROUP BY Prod_List.PCRefNo, Prod_List.Product_Code, Prod_List.Company_Name, Prod_List.Brand, Prod_List.Model, Prod_List.Prod_Type,
Prod_List.Thinkness, Prod_List.T_Unit, Prod_List.Width, Prod_List.W_Unit, Prod_List.Length, Prod_List.L_Unit, Prod_List.Status, Prod_List.Cost
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
END
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
May 6th, 2008, 06:25 AM
#2
Re: What problem of my store procedure ?
Well, perhaps if you told us what problem you are having, some solutions could be suggested.
-
May 6th, 2008, 06:40 AM
#3
Re: What problem of my store procedure ?
As Hack says, giving us a clue as to what's wrong might help. I can see that you've got the structure of the alter statement wrong at a glance though. The 'Begin' and 'Set No Count On' lines should be before your functional statements. Is this what you're after?:-
Code:
USE [Local Mattress System]
GO
/******
Object: StoredProcedure [WANSERN\wansern].[SP_LoadProduct]
Script Date: 05/06/2008 15:18:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Chia Chet Shian
-- Create date: 06/05/2008
-- Description: Load Spec Product
-- =============================================
ALTER PROCEDURE [WANSERN\wansern].[SP_CreateViewProd]
-- Add the parameters for the stored procedure here
@PCRefNo varchar(50),
@ProductCode varchar(50),
@Company_Name varchar(100),
@Brand varchar(250),
@Model varchar(250),
@Prod_Type varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
IF OBJECT_ID(N'View_ProdList',N'V')IS NOT NULL
DROP VIEW VIEW_ProdList
GO
CREATE VIEW View_ProdList AS
SELECT Prod_List.PCRefNo,Prod_List.Product_Code,Prod_List.Company_Name, Prod_List.Brand, Prod_List.Model, Prod_List.Prod_Type,Prod_List.Thinkness, Prod_List.T_Unit, Prod_List.Width, Prod_List.W_Unit, Prod_List.Length, Prod_List.L_Unit, Prod_List.STATUS, Prod_List.Cost
FROM Prod_List
WHERE Prod_List.PCRefNo = @PCRefNo
AND Prod_List.Product_Code LIKE %@ProductCode%
AND Prod_List.Company_Name LIKE %@Company_Name%
AND Prod_List.Brand = %@Brand%
AND Prod_List.Model = %@Model%
AND Prod_List.Prod_Type LIKE %@Prod_Type%
GROUP BY Prod_List.PCRefNo, Prod_List.Product_Code, Prod_List.Company_Name, Prod_List.Brand, Prod_List.Model, Prod_List.Prod_Type, Prod_List.Thinkness, Prod_List.T_Unit, Prod_List.Width, Prod_List.W_Unit, Prod_List.Length, Prod_List.L_Unit, Prod_List.STATUS, Prod_List.Cost
END
The clue as to where to place your code is in this line:-
-- Insert statements for procedure here
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
May 6th, 2008, 06:59 AM
#4
Thread Starter
Hyperactive Member
Re: What problem of my store procedure ?
Thanks Sir, I'm not similar to store procedure thus i can't know what problem of me.
Hereby,I Executed the code u provided 2 error occured.
1) Procedure SP_CreateViewProd Line 20 Incorrect Syntax near 'VIEW_ProdList'
2) Procedure View_ProdList, Line 9
Incorrect Syntax near the keywork 'END'.
Thanks for help me ^^
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
May 6th, 2008, 08:39 AM
#5
Re: What problem of my store procedure ?
Did you make the change FunkyDexter suggested?
-
May 6th, 2008, 10:37 AM
#6
Re: What problem of my store procedure ?
Please cut and paste the code straight out of your query window and onto the forum. That'll let us see exactly what you're running.
Also, double click on each of those errors in the messages pane and let us know which line it highlights.
I can't see anything obviously wrong with what I posted but it's often hard to be sure. The more info you give us the more likely we can help you.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|