Results 1 to 5 of 5

Thread: very strnage string trancate issue

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    very strnage string trancate issue

    Hi.
    I have an sproc that works flawless.
    I just added a nvarcahr(150) column and I am getting string would be trancated error
    I can also get this to go away with setting ansi warnings off.

    This is the line that has the issue

    Code:
    blah,
    @Customercomments as nvarchar(150),
    
    blah,
    
    insert into ZZ_OPSAssigned (Transnumber,xid,card,CreatedUserID,CreatedDTM,CRInitialValue,CRCustomerData)
    	    values (@TransactionNumber,@xid,(Select [codeCHANGEDTHAT AS VB WILL TAKE IT AS A CODETAG AND WILL BS ] From @Updated),@user,getdate(),@moneynv,@Customercomments)
    If i remove the last field it will work fine. Also note that user and card are nvarchar but i did not have an issue.
    Also note that the sp is in BEGIN TRANSACTION , if that makes any difference.
    As I've said I can get by if I set ansi warnings but I never needed to do that before.
    And of course I send less than 200 chars. I tried sending '','x' etc
    Any thoughts?

    here is the table also:

    Code:
    CREATE TABLE [dbo].[ZZ_OPSAssigned](
    	[xID] [nvarchar](2) NOT NULL,
    	[TransNumber] [int] NOT NULL,
    	[Card] [nvarchar](17) NOT NULL,
    	[CreatedUserID] [nvarchar](50) NOT NULL,
    	[CreatedDTM] [datetime] NOT NULL,
    	[CRInitialValue] [money] NOT NULL,
    	[CrCustomerData] [nvarchar](150) NULL CONSTRAINT [DF_ZZ_OPSAssigned_CrCustomerData]  DEFAULT ((0)),
     CONSTRAINT [PK_ZZ_OPSAssigned] PRIMARY KEY CLUSTERED 
    (
    	[xID] ASC,
    	[TransNumber] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    GO
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: very strnage string trancate issue

    Why do you have a Default when you allow Null?
    Would have expected to be enough
    Code:
    [CrCustomerData] [nvarchar](150),
    OTOH, this would make more sense.
    It would Default to empty String if no value is provided
    Code:
    [CrCustomerData] [nvarchar](150) NOT NULL CONSTRAINT [DF_ZZ_OPSAssigned_CrCustomerData] DEFAULT (''),
    Last edited by Zvoni; May 5th, 2022 at 03:44 AM.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: very strnage string trancate issue

    Yes that is a leftover from tests.
    I would remove it but i don't think it makes a difference on the issue.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: very strnage string trancate issue

    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: very strnage string trancate issue

    Altho we have SQL Server 2012 and 2012R2 the example shows the same principles and eventually advise if everything fails to use Ansi Warning. Fine but again I don't have a clue why the server is doing what it does. It's not a language issue as it fails even on '' , it's not a size issue and the other columns that are nvarchar did not complain before. I'm inclinde to believe there is something wrong with Begin Tran as I seem to remember and issue in the past using it...
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width