Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: SQL challenge ?

  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL challenge ?

    Once I found the product say in case one or two I don’t want to execute the query… How do I do that?

    SELECT * FROM [dbo].[SupplierCatalogue]
    (1 = CASE WHEN @pi_vProductCode IS NULL
    THEN 1
    ELSE
    CASE WHEN [PRODTCDE] LIKE @pi_vProductCode + '%'
    THEN 1
    ELSE
    CASE WHEN [DESCRPTN] = @pi_vProductCode
    THEN 1
    ELSE
    CASE WHEN [DESCRPTN] LIKE @pi_vProductCode + '%'
    THEN 1
    ELSE
    CASE WHEN (SELECT COUNT(SplitValue) FROM dbo.Split(@pi_vProductCode,' ') WHERE [DESCRPTN] LIKE '%' + SplitValue + '%'

    AND LEN(SplitValue) > 1 ) > 0
    THEN 1
    ELSE
    0
    END
    END
    END
    END
    END)
    ORDER BY [GOVPREXC] ASC

  • #2
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rather than having all the "case" options, I thought why not just use a large query with multiple "where" options, return more than 1 row (and lots of columns) and deal with it in the front end. However, I cannot take that approach bcoz it involve lots of modification in front end. Any other way ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •