locked
Unicode T-Sql RRS feed

  • Question

  • Helloo

    Is there a way so this query can work

    --------------------------------------------------------------------------------------------------
    CREATE PROCEDURE test1
    @search nvarchar(50)=null
    AS

    select c.cId, c.cCode, c.cDesc, c.cPresident, c.groupId, g.groupName
    from center c inner join CenterGroups g on c.groupId = g.groupId
    where c.cDesc like N@search + '%'
    GO
    --------------------------------------------------------------------------------------------------

    Knowing that @search is parameter sent from vb.net application???

    Plzzzzzz Help

    Thursday, October 12, 2006 4:06 AM

Answers

  • >>CREATE PROCEDURE test1
    @search nvarchar(50)=null
    AS

    select c.cId, c.cCode, c.cDesc, c.cPresident, c.groupId, g.groupName
    from center c inner join CenterGroups g on c.groupId = g.groupId
    where c.cDesc like N@search + '%'
    GO<<

    The N is superflous.  The @search value is already UNICODE because the parameter is declared as nvarchar

    >>man didnt u see that @search is nvarchar <<

    @Search + '%' will be unicode as well, as the unicode types are higher on the data type precedence chart (look up "data type precedence" in books online.)

    You could change to: @search + N'%' if you want to.

     

    Thursday, October 12, 2006 6:05 AM

All replies

  • Try this..

    select c.cId, c.cCode, c.cDesc, c.cPresident, c.groupId, g.groupName
    from center c inner join CenterGroups g on c.groupId = g.groupId
    where c.cDesc like @search + '%'

    Thursday, October 12, 2006 4:48 AM
  • man didnt u see that @search is nvarchar
    Thursday, October 12, 2006 4:54 AM
  • >>CREATE PROCEDURE test1
    @search nvarchar(50)=null
    AS

    select c.cId, c.cCode, c.cDesc, c.cPresident, c.groupId, g.groupName
    from center c inner join CenterGroups g on c.groupId = g.groupId
    where c.cDesc like N@search + '%'
    GO<<

    The N is superflous.  The @search value is already UNICODE because the parameter is declared as nvarchar

    >>man didnt u see that @search is nvarchar <<

    @Search + '%' will be unicode as well, as the unicode types are higher on the data type precedence chart (look up "data type precedence" in books online.)

    You could change to: @search + N'%' if you want to.

     

    Thursday, October 12, 2006 6:05 AM
  • Thanks man
    Thursday, October 12, 2006 3:32 PM