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
 Transact-SQL (2000)
 truncates varchar(8000) to char(4000)

Author  Topic 

marat
Yak Posting Veteran

85 Posts

Posted - 2006-03-03 : 06:41:05
Hi,
I am building dynamic query, something like
select [a] as [a1],[b] as [b2], .... into tbl1 from tbl2

I declared @sql varchar(8000)
but final result of @sql is truncated to 4000 characters.
What could cause a truncation?
Thanks

Kristen
Test

22859 Posts

Posted - 2006-03-03 : 06:56:00
Sounds like something is using Nvarchar - which has a limit of 4,000 characters.

If that isn't the answer pls post the exact code you are using and we can take a look.

Kristen
Go to Top of Page

marat
Yak Posting Veteran

85 Posts

Posted - 2006-03-03 : 07:22:38
Actually,
problem was with @tbl1 and @tbl2 variables.
I declared then as "sysname"
After changing to varchar(2000), everything start working.
Thanks Kristen for the idea
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-03 : 07:53:00
Whenever asking the question post the code so that we will be able to point out error without guessing what the reason is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-03-03 : 07:56:12
sysname is a synonym for nvarchar(128) - so that would explain it!

Kristen
Go to Top of Page
   

- Advertisement -