Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Dynamic Sql in sql2005

Author  Topic 

GhantaBro
Posting Yak Master

215 Posts

Posted - 2009-07-05 : 18:35:01
Guys I made the variable @nsql nvarchar(max) to be used for dynamic sql. When I execute using sp_executesql, it throws me error and seems like the sql that it was trying to run was incomplete (4000 chars only and it is where it throws error).... I was able to use workaround by using two variables and using

Exec(@var1 + @var2) ... But not sure why would nvarchar(max) not work?

Anyone going through this issue? I am using sql server 2005 enterprise edition... thanks!

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-06 : 03:37:38
Hi

Is a Unicode string that contains a Transact-SQL statement or batch. stmt must be either a Unicode constant or a Unicode variable. More complex Unicode expressions, such as concatenating two strings with the + operator, are not allowed. Character constants are not allowed. If a Unicode constant is specified, it must be prefixed with an N. For example, the Unicode constant N'sp_who' is valid, but the character constant 'sp_who' is not. The size of the string is limited only by available database server memory. On 64-bit servers, the size of the string is limited to 2 GB, the maximum size of nvarchar(max).



-------------------------
Your time is a valuable resource.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-07-06 : 06:22:36
What error does it throw?

Can you post the sql?


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -