wildcards

  • Moderator, please end this topic... :pinch:

  • Yeah, my initial thought was "2, if my instance of 2008R2 properly handles regex, we'll see..." So I ran the code and got the error:

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ','.

    So I ended up choosing 0, assuming that was the stand-in for an error message. I'unno, maybe it works properly on 2012?

    Not saying I deserve a point or anything, I certainly was wrong. I guess I'm just asking: If it's not specified in the question, are we meant to always assume the newest version of SQL Server?

  • Drew Copenhaver (9/16/2013)


    Yeah, my initial thought was "2, if my instance of 2008R2 properly handles regex, we'll see..." So I ran the code and got the error:

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ','.

    So I ended up choosing 0, assuming that was the stand-in for an error message. I'unno, maybe it works properly on 2012?

    Not saying I deserve a point or anything, I certainly was wrong. I guess I'm just asking: If it's not specified in the question, are we meant to always assume the newest version of SQL Server?

    I'm not sure that's true. I ran this on my R2 instance and it worked. The regex stuff in LIKE should have been there far earlier. I don't have a SS2K or SS2K5 instance handy, but I think it worked then.

    Your error is a syntax error, which might be a transcription or cut/paste error.

  • Steve Jones - SSC Editor (9/16/2013)


    Drew Copenhaver (9/16/2013)


    Yeah, my initial thought was "2, if my instance of 2008R2 properly handles regex, we'll see..." So I ran the code and got the error:

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ','.

    So I ended up choosing 0, assuming that was the stand-in for an error message. I'unno, maybe it works properly on 2012?

    Not saying I deserve a point or anything, I certainly was wrong. I guess I'm just asking: If it's not specified in the question, are we meant to always assume the newest version of SQL Server?

    I'm not sure that's true. I ran this on my R2 instance and it worked. The regex stuff in LIKE should have been there far earlier. I don't have a SS2K or SS2K5 instance handy, but I think it worked then.

    Your error is a syntax error, which might be a transcription or cut/paste error.

    My mistake. I don't think it's a syntax or copy past error, though. We've got two servers running different instances of SQL here. I played with the syntax and couldn't get it to work on what I believe is the 2008 box, but it did work on our other server which is running 2005 and it ran with the correct results. I'm stumped. Might just ask our DBA later and see what he thinks.

  • Drew Copenhaver (9/16/2013)


    Steve Jones - SSC Editor (9/16/2013)


    Drew Copenhaver (9/16/2013)


    Yeah, my initial thought was "2, if my instance of 2008R2 properly handles regex, we'll see..." So I ran the code and got the error:

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ','.

    So I ended up choosing 0, assuming that was the stand-in for an error message. I'unno, maybe it works properly on 2012?

    Not saying I deserve a point or anything, I certainly was wrong. I guess I'm just asking: If it's not specified in the question, are we meant to always assume the newest version of SQL Server?

    I'm not sure that's true. I ran this on my R2 instance and it worked. The regex stuff in LIKE should have been there far earlier. I don't have a SS2K or SS2K5 instance handy, but I think it worked then.

    Your error is a syntax error, which might be a transcription or cut/paste error.

    My mistake. I don't think it's a syntax or copy past error, though. We've got two servers running different instances of SQL here. I played with the syntax and couldn't get it to work on what I believe is the 2008 box, but it did work on our other server which is running 2005 and it ran with the correct results. I'm stumped. Might just ask our DBA later and see what he thinks.

    Given the line the error was on, it's in the values clause not in the regexp. The ability to specify more than one row in the values clause was not in SQL 2000 or 2005, but is in SQL 2008 (and onwards). That's your syntax error detecded at a comma, which must have occurred running it against 2005 or an earlier version, where the insert statement has invalid syntax. So perhaps you have mistaken the 2005 box for the 2008 box and vice versa?

    Tom

  • L' Eomot Inversé (9/16/2013)


    Drew Copenhaver (9/16/2013)


    Steve Jones - SSC Editor (9/16/2013)


    Drew Copenhaver (9/16/2013)


    Yeah, my initial thought was "2, if my instance of 2008R2 properly handles regex, we'll see..." So I ran the code and got the error:

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ','.

    So I ended up choosing 0, assuming that was the stand-in for an error message. I'unno, maybe it works properly on 2012?

    Not saying I deserve a point or anything, I certainly was wrong. I guess I'm just asking: If it's not specified in the question, are we meant to always assume the newest version of SQL Server?

    I'm not sure that's true. I ran this on my R2 instance and it worked. The regex stuff in LIKE should have been there far earlier. I don't have a SS2K or SS2K5 instance handy, but I think it worked then.

    Your error is a syntax error, which might be a transcription or cut/paste error.

    My mistake. I don't think it's a syntax or copy past error, though. We've got two servers running different instances of SQL here. I played with the syntax and couldn't get it to work on what I believe is the 2008 box, but it did work on our other server which is running 2005 and it ran with the correct results. I'm stumped. Might just ask our DBA later and see what he thinks.

    Given the line the error was on, it's in the values clause not in the regexp. The ability to specify more than one row in the values clause was not in SQL 2000 or 2005, but is in SQL 2008 (and onwards). That's your syntax error detecded at a comma, which must have occurred running it against 2005 or an earlier version, where the insert statement has invalid syntax. So perhaps you have mistaken the 2005 box for the 2008 box and vice versa?

    That syntax works only in 2008 onwards

    http://technet.microsoft.com/en-us/library/dd776382.aspx

    Cheers

  • L' Eomot Inversé (9/16/2013)


    Drew Copenhaver (9/16/2013)


    Steve Jones - SSC Editor (9/16/2013)


    Drew Copenhaver (9/16/2013)


    Yeah, my initial thought was "2, if my instance of 2008R2 properly handles regex, we'll see..." So I ran the code and got the error:

    Msg 102, Level 15, State 1, Line 3

    Incorrect syntax near ','.

    So I ended up choosing 0, assuming that was the stand-in for an error message. I'unno, maybe it works properly on 2012?

    Not saying I deserve a point or anything, I certainly was wrong. I guess I'm just asking: If it's not specified in the question, are we meant to always assume the newest version of SQL Server?

    I'm not sure that's true. I ran this on my R2 instance and it worked. The regex stuff in LIKE should have been there far earlier. I don't have a SS2K or SS2K5 instance handy, but I think it worked then.

    Your error is a syntax error, which might be a transcription or cut/paste error.

    My mistake. I don't think it's a syntax or copy past error, though. We've got two servers running different instances of SQL here. I played with the syntax and couldn't get it to work on what I believe is the 2008 box, but it did work on our other server which is running 2005 and it ran with the correct results. I'm stumped. Might just ask our DBA later and see what he thinks.

    Given the line the error was on, it's in the values clause not in the regexp. The ability to specify more than one row in the values clause was not in SQL 2000 or 2005, but is in SQL 2008 (and onwards). That's your syntax error detecded at a comma, which must have occurred running it against 2005 or an earlier version, where the insert statement has invalid syntax. So perhaps you have mistaken the 2005 box for the 2008 box and vice versa?

    Yes, that's actually what I was thinking, too. I just asked our DBA and that is indeed the case. I had my servers swapped. I figured it might be something like that. I remember having a similar issues a few months ago because one of the servers supported what I wanted to do and the other (the one I needed) didn't. Thanks for the help, guys!

  • ksatpute123 (9/11/2013)


    Ahh! Too many posts and none adding any value to the topic of discussion.

    Wrong question or not, if it was able to teach you something new or refresh your memory about things you knew but had forgotten then it's worth it.

    Go write your own QoTD and share knowledge with everyone.

    Seconded

  • Koen Verbeeck (9/11/2013)


    Vobr Jiri (9/11/2013)


    In SS2k you must use in T-SQL script this version:

    INSERT @i VALUES ('Steve')

    INSERT @i VALUES ('Stephan')

    INSERT @i VALUES ('Stephanie')

    INSERT @i VALUES ('Sterling')

    INSERT @i VALUES ('Steppenwolf')

    Then are 4 rows in the table @i inserted and correct answer is 2.

    SQL Server 2000 is no longer considered as a possible edition in the Questions.

    That's a shame, we've still got three or four customers using it who are totally resistant to moving to 2005 let alone 2008 or later.

  • nice question... i got +1:-)

    actually there is only nvarchar(50) only

    DECLARE @i TABLE( mychar VARCHAR(50));

    INSERT @i VALUES ('Steve'), ('Stephan'), ('Stephanie')

    , ('Sterling'), ('Steppenwolf')

    SELECT mychar

    FROM @i

    WHERE mychar LIKE 'Ste[^p]%'

    Manik
    You cannot get to the top by sitting on your bottom.

  • I learnt something new so thanks Steve.:-D

Viewing 11 posts - 136 through 145 (of 145 total)

You must be logged in to reply to this topic. Login to reply