简体   繁体   中英

SQL execution returns different results than execution directly in MS SQL Server Management Studio

I have quite confusion with SQL, so maybe I am doing something wrong.

I was trying to build a query which will display results from several SELECT's. The code is very simple, but in general it goes like this:

with results into sql text option

select  MessageId from   NsDelivery..NudgeResponseDump (NOLOCK) where Pk_RowId = 28901649

output

0:1550774328341685 9d012f009d012f

with out results into sql text option

    select  MessageId from   NsDelivery..NudgeResponseDump (NOLOCK) where Pk_RowId = 28901649

output

0:1550774328341685

I dont know why string data is missing in second option please give me valid explanation...

I'm guessing there's a null-character (aka null terminator) between the two parts of the string (not NULL value, but CHAR(0) ). This character causes the string to be cut off in results to grid mode. There's some information here . Essentially, the last part of the string is there, but in the visualization it is cut off due to the null-character. You can test it by casting the string to a VARBINARY , a null-character will show up as 00 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM