I guess this happens because there is a NUL character in the data. And yes, SSMS thinks that NUL (a.k.a \0) is the end of string, and then things go downhill from there.
How the NUL got into your data, I don't know.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I ran the Generate Scripts task on a table that has around 25k rows in SQL Server 2016. The result was a script file that contains the schema and data, was about 16MB. At first I tried to use the sqlcmd command to to run the script against another database; even after using the max value for packet size, it would still cut off after about 11K records. At first, I tried to open the .sql file in SMSS and run it, but it would error out due to a syntax error but everything on that line of the file looked fine. I then opened the .sql file in VS Code and noticed a strange NUL character with a red background in that spot that was failing. I replaced the NUL character with a space in all occurrences and everything was working fine after that. I have attached a screenshot.
Has anyone seen this issue or know why it happens? It's not that large of a table and I have ran scripts against much larger tables that worked fine.
Thanks, Igor
I guess this happens because there is a NUL character in the data. And yes, SSMS thinks that NUL (a.k.a \0) is the end of string, and then things go downhill from there.
How the NUL got into your data, I don't know.
Some of this data was generated in the 70s and migrated from a mainframe so that might explain why.