开发者

How do I remove spaces from a column's value and make it lower case and then compare it with the parametre passed?

开发者 https://www.devze.com 2023-02-20 23:34 出处:网络
Let\'s say I pass this parametre value\"aboutme\" to my Stored procedure. In my table \"PagesTable\" I have a column named \"PageName\" that has values like \"About Me\" , \"About Company\", etc. Now

Let's say I pass this parametre value "aboutme" to my Stored procedure. In my table "PagesTable" I have a column named "PageName" that has values like "About Me" , "About Company", etc. Now what I want is compare the parametre passed (aboutme ie) with these column values. So I need to first convert the column values to lower case and remove the spaces in between and only then can I compare.

Someone please tell me how do you accomplish this in MSSQL? Any help will be greatly a开发者_开发百科preciated. Thanks :)


    DECLARE   @yourString   VARCHAR(100)
    SET   @yourString =   'HI HOW ARE YOU'

    SELECT LOWER( REPLACE( @yourString, ' ', '' ) )

For comparison against a value

    WHERE LOWER( REPLACE( ColumnName, ' ', '' ) ) = @val
0

精彩评论

暂无评论...
验证码 换一张
取 消