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.
| Author |
Topic |
|
cr8nk
Yak Posting Veteran
77 Posts |
Posted - 2008-10-30 : 17:45:36
|
| Hi all,I am dynamically concatenating a string with FOR XML PATH('') and I am wondering what data type and length I am returning when using it. Here is an example of the code[CODE]DECLARE @i int ,@Len intDECLARE @Number TABLE(n int)SELECT @i = 1WHILE @i <= 10000BEGIN INSERT INTO @Number VALUES (@i) SET @i = @i + 1 ENDSELECT STUFF( (SELECT ',' + CAST(N AS varchar) FROM @Number FOR XML PATH('') ), 1, 1, ' ') SELECT @Len = LEN ( STUFF( (SELECT ',' + CAST(N AS varchar) FROM @Number FOR XML PATH('') ), 1, 1, ' ')) SELECT @Len[/CODE]I am assuming that it is varchar(max) because when I check the length of the string it can be well over 8000. Just wondering if there is an easier way to tell.Thanks! |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-10-30 : 18:18:16
|
| correct, varchar(max) replaces text and adds compatibilities. |
 |
|
|
|
|
|