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
Re: What problem of my store procedure ?
Well, perhaps if you told us what problem you are having, some solutions could be suggested.
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
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 ^^
Re: What problem of my store procedure ?
Did you make the change FunkyDexter suggested?
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.:)