SQL Views - error messages

  • I'm having trouble with the following phrase:

    Server: Msg 8152, Level 16, State 4, Line 1

    String or binary data would be truncated.

    The statement has been terminated.

    (0 row(s) affected)

    Not sure what to do. VERY much a SQL Newbie (Please, Please, anyone that can help?!?) I just need help finding out how to fix the "string or binary data would be truncated" part. Thank you!

    Here is my code:  

    USE Northwind

    GO

    CREATE VIEW SpainView

    AS

    SELECT OrderID, ShipCountry

    FROM Orders

    WHERE ShipCountry = 'Spain'

    GO

    UPDATE SpainView

    SET ShipCountry = 'DestinationSpain'

    WHERE ShipCountry = 'Spain'

    DELETE FROM SpainView WHERE ShipCountry!= 'Spain'

    GO

     

     

  • From the information you've posted I'd say the length of the ShipCountry field is shorter than the data you want to put into it. "DestinationSpain" is 16 chars long so the ShipCountry field will need to be a varchar or char field that is 16 chars or longer.

     

     

    --------------------
    Colt 45 - the original point and click interface

  • Ok, thank you, I'll fix that and see how it goes.

    Thanks again, Phill,

    Lilly

  • SET ANSI_WARNINGS OFF

    ...

    Your query

    ..

    SET ANSI_WARNINGS ON


    Moe C

  • And this fixes the data truncation how ??

     

    --------------------
    Colt 45 - the original point and click interface

  • It does not fix it but if the fields are correct in length and you still getting the same error message for what ever reason, I have use this code to stop giving me those error messages because i have combed through all the characters in that field and they do not exceed varchar(50) ...


    Moe C

  • ??? where does varchar(50) come into it? I don't recall seeing where the poster mentioned anything about field definitions. Are you working on some other problem?

     

    --------------------
    Colt 45 - the original point and click interface

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply