Results 1 to 3 of 3

Thread: updates, inserts

  1. #1
    Sridhar Raman Guest

    updates, inserts

    I have a number of columns with predefined character length but user can input more from gui. i want to trucncate automatically to the desired length and insert or update the database right now it does not allow me to update , or insert the values can i do it and how this is urgent

  2. #2
    JK Guest

    updates, inserts (reply)

    Use convert functions... Suppose you have table called Employee which having Name char(50) length. But user enter 60 characters
    from Gui

    UPDATE
    SET NAME = CONVERT(CHAR(50),@NAME)
    Thanks
    JK





    ------------
    Sridhar Raman at 1/22/01 11:44:21 AM

    I have a number of columns with predefined character length but user can input more from gui. i want to trucncate automatically to the desired length and insert or update the database right now it does not allow me to update , or insert the values can i do it and how this is urgent

  3. #3
    Greg G. Guest

    updates, inserts (reply)

    You could also set ansi_warnings off.
    Something like this.

    SET ANSI_WARNINGS OFF
    GO
    INSERT INTO table (cola int, colb varchar(20)
    VALUES (1, 'This is only a test, this may help you!!!!!!&#39
    GO
    SET ANSI_WARNINGS ON

    Make sure you turn the warnings back on after the Insert. This will truncate the data to the length of the field without errors.

    Thanks
    Greg


    ------------
    JK at 1/22/01 12:28:42 PM

    Use convert functions... Suppose you have table called Employee which having Name char(50) length. But user enter 60 characters
    from Gui

    UPDATE
    SET NAME = CONVERT(CHAR(50),@NAME)
    Thanks
    JK





    ------------
    Sridhar Raman at 1/22/01 11:44:21 AM

    I have a number of columns with predefined character length but user can input more from gui. i want to trucncate automatically to the desired length and insert or update the database right now it does not allow me to update , or insert the values can i do it and how this is urgent

Posting Permissions

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