SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Stored Procedure explanation


Stored Procedure explanation

Author
Message
niha.736
niha.736
SSC Journeyman
SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)SSC Journeyman (96 reputation)

Group: General Forum Members
Points: 96 Visits: 233
Hi all,
this is the first time am working on stored procedures, I need to make changes to the existing SP and to use new altered SP in my reports.

Can anybody explain the follwing SP, then I may able to make changes to that and use.
How can I go with this SP's while creating or modifying.

please help me

Create PROCEDURE [dbo].[getNotificateProduct]
@search as varchar(1000),
@store as varchar(50),
@lan as varchar(2)
AS
BEGIN

Declare @haku varchar(50)
declare @temp as table (ParameterCaption varchar(100), ParameterValue varchar(100))

IF substring(@search, LEN(@search),1)<>';'
SET @search = @search + ';'

while CHARINDEX(';',@search)>0
BEGIN
SET @haku=UPPER(LTRIM(cast(substring(@search,0, charindex(';',@search)) as varchar(50))))

INSERT INTO @temp
SELECT CASE
WHEN @lan ='FI' THEN
[Material_FI]
WHEN @lan ='EN' THEN
[Material_EN]
END AS ParameterCaption,
'[Material DIM].[Material FI].&['+ CAst([DimCubeProduct].[ProductKey] as varchar(50))+ ']' AS ParameterValue
FROM [DimCubeProduct] INNER JOIN
FactStoreQualityNotification ON [DimCubeProduct].[ProductKey] = FactStoreQualityNotification.[ProductKey] AND
Charindex(Cast(FactStoreQualityNotification.StoreKey as varchar(5)),@store)>0
WHERE (@haku = '') OR
(
(@lan='FI' AND CHARINDEX(@haku, UPPER([Material_FI])) > 0)
OR
(@lan='EN' AND CHARINDEX(@haku, UPPER([Material_EN])) > 0)
)
ORDER BY [ProductID]

SET @search = substring(@search, charindex(';',@search)+1, LEN(@search) - 0)
end

SELECT DISTINCT * FROM @temp
END



GO



Thanks,
Mackers
Mackers
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 499
What bit don't you understand?

If the answer is all of it then you may need to look at TSQL tutorials online...

Mack
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25815 Visits: 17509
Please don't cross post. Direct all replies here. http://www.sqlservercentral.com/Forums/Topic1412195-391-1.aspx

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search