• 0

[SQL] Varchar cutting off my string!


Question

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

  • 0

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>'

  • 0

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...

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Sony started with 70 Euro games, Nintendo with 80 Euro games.
    • It has only been about 2 years since Microsoft raised prices from $60 to $70! I don't think it's a good idea they are doing it again so soon. Instead of raising prices, manage game development budgets better.
    • Intel's 20-core Ultra 7 processor is now available with a massive discount by Taras Buria The Intel Core Ultra 7 265K, Intel's latest 20-core desktop processor, is getting more affordable. Now, the chip is available on Amazon with a 36% discount, saving you $144, which you can spend on a higher-spec graphics card, better cooling, a bigger SSD, or some new games. If you want to build a computer with the discounted Intel Core Ultra 7 265K, you will need a motherboard with the LGA 1851 socket and 800 series chipset. The Core Ultra 7 265K has 20 cores, 8 of which are performance cores, and 12 are efficiency cores operating at lower clocks for less demanding tasks. Performance cores have the maximum clock speed of 5.4GHz, while efficiency cores peak at 4.6GHz. However, the processor is unlocked, which means you can push those clocks higher if you have enough cooling and a motherboard that supports overclocking. Speaking of cooling, the processor has a TDP of 125W. A cooler is not included in the box, so do not forget to add one to your shopping cart. The Intel Core Ultra 7 265K has 30MB of level 3 cache (L3). It works with DDR5 memory (rated for 6,400 MT/s) and has a built-in graphics at 2GHz, which is enough for image output, media consumption, and all sorts of tasks that do not require a lot of GPU power. There is also a neural processing unit with 13 TOPS, which can handle on-device AI processing. Intel Core Ultra 7 Desktop Processor 265K 5.5 GHz - $259.99 | $144 off on Amazon US This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • It's stuff like this countries like Denmark are giving up by switching to Linux. Good luck to them.
    • I think a big part of it is developers have grown themselves too big and ballooned their budgets. It's the only way to show endless growth to investors between releases. Then they make massive investments in games designed for the bottom line hoping players follow instead of designing them for the players and hoping the bottom line follow in the way smaller, indie developers do. This often causes the games to fail to hook players. Instead they need to streamline development, lower budgets and sales forecasts, actually listen to gamer feedback, realize that social media doesn't dictate real world gaming tastes and habits, and overall learn to adapt instead of regurgitating the same formulas over and over.
  • Recent Achievements

    • Week One Done
      bukro earned a badge
      Week One Done
    • One Year In
      Wulle earned a badge
      One Year In
    • One Month Later
      Wulle earned a badge
      One Month Later
    • One Month Later
      Simmo3D earned a badge
      One Month Later
    • Week One Done
      Simmo3D earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      552
    2. 2
      ATLien_0
      246
    3. 3
      +FloatingFatMan
      167
    4. 4
      Michael Scrip
      121
    5. 5
      Steven P.
      95
  • Tell a friend

    Love Neowin? Tell a friend!