In the upcoming series of short posts, I would like to describe how some common developer tasks in .NET ecosystem can be automated via Powershell.
The list follows:
– Create a website on IIS, including creation and usage of self-signed certificate
– Setting Sql Server authentication mode and creating database logins
– Creating a database based on Visual Studio Database Project
– Executing Sql queries
– Calling REST APIs
Today, I found a reason why Sql Server Management Studio refused to edit a row in a table with “String or binary data would be truncated” error. I checked all columns content, and they were perfectly fitting their column definitions; and there were no triggers for that table at all.
Using a profiler, I found that actual SQL it tried to perform is UPDATE with some extra optimistic concurrency-looking checks:
UPDATE TOP(200) Table SET Field1 = @Field1 WHERE (Id = @Param1) AND … (Field2 LIKE @Param2)
Now, @Param2 was a 10KB text which lived nicely in a ntext column, except LIKE pattern cannot be longer than 8,000 bytes according to the documentation!
Good work, SSMS 🙂