i am using 开发者_Python百科DTS to export data to text file. but some fields are of type varchar(max) and the max size i can specify is varchar(8000). Hence text is getting truncated how can i avoid this.
I am not sure, but I have some logical ways :
1) either you have to add new column
, say col1 & col2. Then apply "substring" query on your data, part data into two(or more) parts, as per your requirement. Then store first part in col1, second in col2...ans so on.
2) you have to add new row
, with above logic, with row1 storing first part, row2 second part and so on.
There is no other way.
Though both ways would work, but I forcibly suggest you should go with 1st way.
**
I have third solution for you, it will work> ** You can declare
**nVARCHAR(MAX)**
instead of nVARCHAR(MAX)
here is an example for you:::
DECLARE @String nVARCHAR(MAX) DECLARE @i INT SELECT @i = 10000,@String=''
WHILE @i>0 BEGIN SELECT @String = @String + 'A' SET @i = @i - 1 END
SELECT LEN(@String) as Length
Output: Length ——————– 10000
(1 row(s) affected)
LEN statement returns 10000 and it proves that varchar(max) can store more than 8000 characters.
I would try and convert it to a Text column. A text column can hold up to 2147483647 bytes of binary data.
Thanks, Andrew
精彩评论