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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sp_execSQL to large of string

Author  Topic 

edpel
Starting Member

22 Posts

Posted - 2004-05-19 : 14:52:55
I am using

declare @i int
exec sp_executesql @out , N'@i int output', @i output

where @out is a dynamically generated string. The datatype is nvarchar(4000) but I noticed in one case that is to small. I won't le me use text as the type, how can I use sp_executesql with a string larger than 4000?

Thanks,
Eddie

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-19 : 14:57:10
You can't with sp_executesql.

Put the string into a @SQL variable, then run EXEC (@SQL). Declare @SQL as VARCHAR(8000).

Tara
Go to Top of Page

edpel
Starting Member

22 Posts

Posted - 2004-05-19 : 15:30:49
yes But I need to get to the output of the dynamic sql...that's is why I am using execute sql:

declare @i int
exec sp_executesql @out , N'@i int output', @i output

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-19 : 15:53:50
You aren't going to be able to do it with sp_executesql. I was going to say to rewrite your own stored procedure, but then I remembered that sp_executesql is an extended stored procedure so you won't be able to see the code.

Are you sure that you really need dynamic sql for what you are doing? There are lots of tricks that you can use to get around it.

Tara
Go to Top of Page
   

- Advertisement -