substring return blank or 0 (zero)

  • hi,

    i have problem with sql server 2017 and 2014 enterprise edition:

    if execute this code from management is all right, while if execute with debug, in window immediately,  'test1' retunr blanck or 0.

    It's like reading the string up to 256 characters and no more, why?

    declare @pippo VARCHAR(MAX) = '55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555999555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555599955555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555999'

    SELECT SUBSTRING(@pippo,256,10) as test1
    SELECT SUBSTRING(@pippo,100,10) as test2

    without debug result

    nodebug

    with debug

    debug

    why?

     

     

    • This topic was modified 4 years, 8 months ago by  emanuele 8962.
    Attachments:
    You must be logged in to view attached files.
  • can you post the code  in text format  please - its easier than all of us manually typing it in

    MVDBA

  • OK,

    Attachments:
    You must be logged in to view attached files.
  • I can't replicate the issue

    have you tried

    declare @result

    select @result=substring(@pippo,256,10)

     

    MVDBA

  • HI,

    in debug, in in window immediately, result blank

    Cattura

    Attachments:
    You must be logged in to view attached files.
  • are you using visual studio or sql management studio ?

    MVDBA

  • sql management studio

Viewing 7 posts - 1 through 6 (of 6 total)

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