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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. clarification

clarification

Scheduled Pinned Locked Moved Database
databasehelpquestion
7 Posts 4 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.
  • H Offline
    H Offline
    Hema Bairavan
    wrote on last edited by
    #1

    hi peoples, select * from table where lower(column) like lower('%test%') this statement works fine for me, but declare @abc char(50) set @abc='%test%' select * from table where lower(column) like lower(@abc) its not working for me? should i go for dynamic query though?? can any one help me? thanks in advance and happy new year

    A A 2 Replies Last reply
    0
    • H Hema Bairavan

      hi peoples, select * from table where lower(column) like lower('%test%') this statement works fine for me, but declare @abc char(50) set @abc='%test%' select * from table where lower(column) like lower(@abc) its not working for me? should i go for dynamic query though?? can any one help me? thanks in advance and happy new year

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Hema Bairavan wrote:

      its not working for me?

      What error you are getting ?

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      H 1 Reply Last reply
      0
      • H Hema Bairavan

        hi peoples, select * from table where lower(column) like lower('%test%') this statement works fine for me, but declare @abc char(50) set @abc='%test%' select * from table where lower(column) like lower(@abc) its not working for me? should i go for dynamic query though?? can any one help me? thanks in advance and happy new year

        A Offline
        A Offline
        Andy_L_J
        wrote on last edited by
        #3

        Try this (I haven't tested)

        DECLARE @ABC VARCHAR(50)
        DECLARE @SQL VARCHAR(1000)
        SET @ABC = '%test%'
        SET @SQL = 'SELECT * FROM table WHERE lower(column) LIKE (''' + @ABC + ''')'
        EXEC (@SQL)

        I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

        H 1 Reply Last reply
        0
        • A Abhijit Jana

          Hema Bairavan wrote:

          its not working for me?

          What error you are getting ?

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          H Offline
          H Offline
          Hema Bairavan
          wrote on last edited by
          #4

          abhijit, i am not getting any error, but the result s not correct, its not filtering the correct data from the database.and sorry for late reply.

          1 Reply Last reply
          0
          • A Andy_L_J

            Try this (I haven't tested)

            DECLARE @ABC VARCHAR(50)
            DECLARE @SQL VARCHAR(1000)
            SET @ABC = '%test%'
            SET @SQL = 'SELECT * FROM table WHERE lower(column) LIKE (''' + @ABC + ''')'
            EXEC (@SQL)

            I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife

            H Offline
            H Offline
            Hema Bairavan
            wrote on last edited by
            #5

            thanks for response andy, regarding dynamic query i can do, but it will affect the perfomance, because it has to compile when ever you are running the select statement(as i m using the same in procedure) my question is y cant a static one?

            D 1 Reply Last reply
            0
            • H Hema Bairavan

              thanks for response andy, regarding dynamic query i can do, but it will affect the perfomance, because it has to compile when ever you are running the select statement(as i m using the same in procedure) my question is y cant a static one?

              D Offline
              D Offline
              DarrenShultz
              wrote on last edited by
              #6

              Haven't tried this, but noticed you are using the type char(50) instead of varchar(50). Is the char(50) adding padded characters to the end of the string, causing it to not match?

              H 1 Reply Last reply
              0
              • D DarrenShultz

                Haven't tried this, but noticed you are using the type char(50) instead of varchar(50). Is the char(50) adding padded characters to the end of the string, causing it to not match?

                H Offline
                H Offline
                Hema Bairavan
                wrote on last edited by
                #7

                yes darren, thanks for your info. me to not noticed the same. its working fine when i execute from the procedure from the SQL Query editor. but if i run from the application (asp.net C#) using command.executereader(), i m not getting the result, do you have any ideea?

                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