$phinX Posted May 11, 2005 Share Posted May 11, 2005 Ive got a long stored proc that adds several strings to a varchar variable at different steps then outputs the full varchar result at the end. Its adding the first 2 strings to the varchar, but it only adds half of the 3rd one and none of the 4th one. I thought maybe the varchar variable was full... but ive set it to VARCHAR(8000) and when i do a LEN() on the final varchar variabl its only 269. Anyone know why its cutting off the end of my varchar!?!? (Using SQL Server 2000 btw) Link to comment https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/ Share on other sites More sharing options...
0 $phinX Posted May 11, 2005 Author Share Posted May 11, 2005 Also... The strings that are being added to the VARCHAR are using CAST(@AnINT AS VARCHAR). Should i be using CONVERT instead? Is there some problem with doing CAST? Link to comment https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/#findComment-585903897 Share on other sites More sharing options...
0 +chorpeac MVC Posted May 11, 2005 MVC Share Posted May 11, 2005 does it have any carriage returns in it? Maybe it is dropped to the next line and you don't see it?? Just a thought. Link to comment https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/#findComment-585903994 Share on other sites More sharing options...
0 $phinX Posted May 11, 2005 Author Share Posted May 11, 2005 No, no carriage returns... Link to comment https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/#findComment-585904023 Share on other sites More sharing options...
0 $phinX Posted May 11, 2005 Author Share Posted May 11, 2005 This is really annoying me now... here is some code... ne1 see whats wrong? DECLARE @NewsMessage VARCHAR(8000) SELECT @NewsMessage = 'Battle Report from Planet ' + PlanetName + '[' + CAST(XPos AS VARCHAR(3)) + ':' + CAST(YPos AS VARCHAR(3)) + ':' + CAST(ZPos AS VARCHAR(3)) + '].<BR>' FROM tblAccount WHERE AccountID = @AccIDUnderAttack SELECT @NewsMessage = @NewsMessage + 'Defending Fleets: ' + CAST(@DefendFleets AS VARCHAR(5)) + '<BR>Defending Ship Quantity: ' + CAST(@DefendTotalShips AS VARCHAR(15)) + '<BR>Defending Ship Luck: ' + CAST(@DefendLuck AS VARCHAR(5)) + '<BR>Defending Ship Loss: ' + CAST(@DefendShipLoss AS VARCHAR(15)) + '<BR>' SELECT @NewsMessage = @NewsMessage + 'Attacking Fleets: ' + CAST(@AttackFleets AS VARCHAR(5)) + '<BR>Attacking Ship Quantity: ' + CAST(@AttackTotalShips AS VARCHAR(15)) + '<BR>Attacking Ship Luck: ' + CAST(@AttackLuck AS VARCHAR(5)) + '<BR>Attacking Ship Loss: ' + CAST(@AttackShipLoss AS VARCHAR(15)) + '<BR>' Link to comment https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/#findComment-585904569 Share on other sites More sharing options...
0 $phinX Posted May 11, 2005 Author Share Posted May 11, 2005 Found out what was goin on... I was using MS SQL Server 2000's Query Analyser application to retrieve these results. It appears the Query Analyser application only lets you display 260 odd characters per line in the results window. And rather than indicate that it had cut off the result from the results pane, and rather than continuing on the line below, it just stops out putting the data. So there is no problem when i run it cos i can see the correct long varchar result in my application (which doesnt limit the result output!). I hope they do something about this for SQL Server 2005's Query Analyser... very dodgy... Link to comment https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/#findComment-585906307 Share on other sites More sharing options...
Question
$phinX
Ive got a long stored proc that adds several strings to a varchar variable at different steps then outputs the full varchar result at the end.
Its adding the first 2 strings to the varchar, but it only adds half of the 3rd one and none of the 4th one.
I thought maybe the varchar variable was full... but ive set it to VARCHAR(8000) and when i do a LEN() on the final varchar variabl its only 269.
Anyone know why its cutting off the end of my varchar!?!?
(Using SQL Server 2000 btw)
Link to comment
https://www.neowin.net/forum/topic/319106-sql-varchar-cutting-off-my-string/Share on other sites
5 answers to this question
Recommended Posts