Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Arabic langauge not display when i make search by arabic langauge why

Arabic langauge not display when i make search by arabic langauge why

Scheduled Pinned Locked Moved Database
databasesharepointhelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmed_sa
    wrote on last edited by
    #1

    Hi guys I have database hr has table Employee this table has field EmployeeName EmployeeName nvarchar(50) when i write in query analyzer : select ^ from Employee where EmployeeName='احمد' not give me any result but when i write select * from Employee where EmployeeName=N'احمد' it give me result meaning it support arabic but i have stored procedure not accept arabic and i dont know how to handel it to accept search by EmployeeName CREATE Procedure sp_EmployeeSelect @EmployeeName nvarchar(50) AS Declare @SQLQuery as nvarchar(2000) SET @SQLQuery ='SELECT * from Employee Where (1=1)' If @EmployeeName <>'' Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE ''%'+@EmployeeName +'%'') ' Exec (@SQLQuery) what is the proplem in this stored procedure and how to solve it please help me

    B Richard DeemingR 2 Replies Last reply
    0
    • A ahmed_sa

      Hi guys I have database hr has table Employee this table has field EmployeeName EmployeeName nvarchar(50) when i write in query analyzer : select ^ from Employee where EmployeeName='احمد' not give me any result but when i write select * from Employee where EmployeeName=N'احمد' it give me result meaning it support arabic but i have stored procedure not accept arabic and i dont know how to handel it to accept search by EmployeeName CREATE Procedure sp_EmployeeSelect @EmployeeName nvarchar(50) AS Declare @SQLQuery as nvarchar(2000) SET @SQLQuery ='SELECT * from Employee Where (1=1)' If @EmployeeName <>'' Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE ''%'+@EmployeeName +'%'') ' Exec (@SQLQuery) what is the proplem in this stored procedure and how to solve it please help me

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      Why don't you apply the solution you found in query analyzer

      select * from Employee where EmployeeName=N'احمد'

      in the stored procedure? I.e.

      Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE N''%'+@EmployeeName +'%'') '

      1 Reply Last reply
      0
      • A ahmed_sa

        Hi guys I have database hr has table Employee this table has field EmployeeName EmployeeName nvarchar(50) when i write in query analyzer : select ^ from Employee where EmployeeName='احمد' not give me any result but when i write select * from Employee where EmployeeName=N'احمد' it give me result meaning it support arabic but i have stored procedure not accept arabic and i dont know how to handel it to accept search by EmployeeName CREATE Procedure sp_EmployeeSelect @EmployeeName nvarchar(50) AS Declare @SQLQuery as nvarchar(2000) SET @SQLQuery ='SELECT * from Employee Where (1=1)' If @EmployeeName <>'' Set @SQLQuery = @SQLQuery + ' AND (EmployeeName LIKE ''%'+@EmployeeName +'%'') ' Exec (@SQLQuery) what is the proplem in this stored procedure and how to solve it please help me

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        I'm repeating myself here: Don't use string concatenation to build a dynamic SQL query. Your code will be susceptible to SQL Injection[^]. If you really need to use a dynamic query, use sp_executesql[^] to execute it:

        CREATE Procedure sp_EmployeeSelect
        @EmployeeName nvarchar(50)
        AS
        Declare @SQLQuery as nvarchar(2000)

        SET @SQLQuery = N'SELECT * from Employee Where (1=1)'
        If @EmployeeName <> ''
        Set @SQLQuery = @SQLQuery + N' AND (EmployeeName LIKE N''%'' + @EmployeeName + N''%'')'

        Exec sp_executesql @SQLQuery,
        N'@EmployeeName nvarchar(50)',
        @EmployeeName

        However, in this case, as with all of your QA questions, you don't need a dynamic query:

        CREATE Procedure sp_EmployeeSelect
        @EmployeeName nvarchar(50)
        AS
        SELECT
        *
        FROM
        Employee
        WHERE
        @EmployeeName = N''
        Or
        EmployeeName Like N'%' + @EmployeeName + N'%'


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups