I want to store a query into a variable and when I execute it, it truncates the value.
Declare @QryStatement varchar(8000)
Set @QryStatement = "Select ...." -- very long statement (less than 8000 chars)
-- display the content of @QryStatement
Select @QryStatement --- This returns a truncated string up to 256 characters.
Exec (@QryStatement) --- This returns an invalid function. It would because it tries to execute an invalid statement.