NVARCHAR The size (8000) given to the parameter exceeds the maximum allowed (4000)

When building dynamic TSQL query string with nvarchar type in MS SQL Server, it is possible to exceed the limit  of 4000 characters, this will causes query string to be truncated and fail to run.

I have no luck with ntext type : The text, ntext, and image data types are invalid for local variables.

varchar is the correct type to use — it has a  limit of 8000 characters

you can define your query string as below:

declare @@querystring varchar(max)


declare @@querystring varchar(8000)


MVC2 LoadingElementID not displaying in Safari

I have a MVC2 project that I am using Ajax form, ajax indicator div (LoadingElementId=”indicator”) displays perfectly in IE, Firefox and Chrome, but it doesn’t display in Safari.

Solution:  change “display:none;” to “visibility:hidden;” in ajax indicator’s css class. Now it works for all browsers above.