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. T-SQL

T-SQL

Scheduled Pinned Locked Moved Database
databasehelpquestion
6 Posts 5 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    why there is a syntax error on 2 ? 1 . set @sql = @sql + N' and (summary like ''%' + @keywords + '%'')' 2 . set @sql = @sql + N' and (summary like ' + '%' + @keywords + '%' + ')'

    S A M 3 Replies Last reply
    0
    • L Lost User

      why there is a syntax error on 2 ? 1 . set @sql = @sql + N' and (summary like ''%' + @keywords + '%'')' 2 . set @sql = @sql + N' and (summary like ' + '%' + @keywords + '%' + ')'

      S Offline
      S Offline
      StylezHouse
      wrote on last edited by
      #2

      I don't see a syntax error, but in number 2, @keywords isn't single quoted... your query will look something like... and (summary like '%somevalue%') and (summary like %somevalue%)

      1 Reply Last reply
      0
      • L Lost User

        why there is a syntax error on 2 ? 1 . set @sql = @sql + N' and (summary like ''%' + @keywords + '%'')' 2 . set @sql = @sql + N' and (summary like ' + '%' + @keywords + '%' + ')'

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

        I would guess it is because the '' in line 1 isn't a quotation mark, but double pings ' which means escaping the second ping. Ping normally starts a string, but if you need pings in the string, you must escape them by adding a ping infront. Thus the string isnt' terminated proberly in line 2. I'd think something along that line? --------------------------- 127.0.0.1 - Sweet 127.0.0.1

        C 1 Reply Last reply
        0
        • L Lost User

          why there is a syntax error on 2 ? 1 . set @sql = @sql + N' and (summary like ''%' + @keywords + '%'')' 2 . set @sql = @sql + N' and (summary like ' + '%' + @keywords + '%' + ')'

          M Offline
          M Offline
          Mattias Olgerfelt
          wrote on last edited by
          #4

          Hi there... this is the problem... U have to have an apostorph after like an you dont... so change the code to: set @sql = @sql + N' and (summary like ''' + '%' + @keywords + '%' + ''')' /M

          1 Reply Last reply
          0
          • A Alsvha

            I would guess it is because the '' in line 1 isn't a quotation mark, but double pings ' which means escaping the second ping. Ping normally starts a string, but if you need pings in the string, you must escape them by adding a ping infront. Thus the string isnt' terminated proberly in line 2. I'd think something along that line? --------------------------- 127.0.0.1 - Sweet 127.0.0.1

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            Alsvha wrote: pings :confused: You mean "apostrophe"


            My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

            A 1 Reply Last reply
            0
            • C Colin Angus Mackay

              Alsvha wrote: pings :confused: You mean "apostrophe"


              My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

              A Offline
              A Offline
              Alsvha
              wrote on last edited by
              #6

              ahh - yeah. I've always myself used and heard ' refered to as a ping when used in code - but yes - it is an apostorphe in english :o sorry - habbits die hard :D --------------------------- 127.0.0.1 - Sweet 127.0.0.1

              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