Stored procedure varchar output parameter

342 views Asked by At

Yesterday, I noticed something odd when returning a varchar(100) output parameter from my stored procedure in my asp.net application. It appears that the returned value is now including the extra white spaces to return a full 100 characters. This behavior is new. The only thing I have changed recently is migrating the project from VS 2015 to 2017. I am using System.Data.SQLClient to connect to the database. Select statements for varchar columns return just the values in the columns and no extra white spaces. Ansi_padding is off for the database and is not set any where in the code.

set @Message = 'Project Updated!' --where @Message is varchar(100)

This will return to the client.

_UpdateStatus = oData.outputParams.Item("@Message") 
_UpdateStatus = "Project Updated!                                                                                    "

Any ideas as to what is happening?

1

There are 1 answers

7
mortb On

Lazy solution:

_UpdateStatus = ((string)oData.outputParams.Item("@Message")).Trim()