Stored Procedure Help Like Syntax

  • This simple stored procedure works FINE!

    ALTER PROCEDURE [dbo].[UB_BH_ANNEX_SP]

    @SitusParam NCHAR(40)

    AS

    BEGIN

    SET NOCOUNT ON;

    SELECT Situs, Compute_URL, RC FROM UB_BH_ANNEX WHERE (Situs LIKE '12%' )

    END

    When I throw in the parameter SitusParam with the %'s it returns NO rows.

    SELECT Situs, Compute_URL, RC FROM UB_BH_ANNEX WHERE (Situs LIKE '%' + @SitusParam + '%' )

    This should be simple... I've tried every permutation of the %'s and quotes I can think of, except I suppose for the one that's right.

  • Try changing that to a varchar so that you don't get the etc blank spaces....

    @SitusParam VARCHAR(40)

    if you called your code as it is now it queries for

    ...

    WHERE (SITUS like '%12 %')

    ...

    Go NVARCHAR if you need unicode.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Change NCHAR to VARCHAR

    works for me 🙂

    Edit: Beaten to it!!

  • Doh, love the simple fixes, thank you so much!!!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply