Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. execute an update  using --> "Exec sp_executesql @Sql1"

execute an update  using --> "Exec sp_executesql @Sql1"

Scheduled Pinned Locked Moved Database
helptoolsquestionannouncement
4 Posts 4 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 11499542
    wrote on last edited by
    #1

    hi, i have a problem while executing updates using the update script inside the variable, it gives the error "String or binary data would be truncated"; I realized that if reduce the number of fields to update, it no longer gives the error! But I didn't want to divide the execution of the update into 2 variables!!! Can you help? Thanks!

    V D L 3 Replies Last reply
    0
    • U User 11499542

      hi, i have a problem while executing updates using the update script inside the variable, it gives the error "String or binary data would be truncated"; I realized that if reduce the number of fields to update, it no longer gives the error! But I didn't want to divide the execution of the update into 2 variables!!! Can you help? Thanks!

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      [https://stackoverflow.com/questions/5591473/error-string-or-binary-data-would-be-truncated-when-trying-to-insert\](https://stackoverflow.com/questions/5591473/error-string-or-binary-data-would-be-truncated-when-trying-to-insert) [String or binary data would be truncated - Google Search](https://www.google.com/search?q=String+or+binary+data+would+be+truncated&rlz=1C1CHBF\_enDE886DE886&sourceid=chrome&ie=UTF-8)

      1 Reply Last reply
      0
      • U User 11499542

        hi, i have a problem while executing updates using the update script inside the variable, it gives the error "String or binary data would be truncated"; I realized that if reduce the number of fields to update, it no longer gives the error! But I didn't want to divide the execution of the update into 2 variables!!! Can you help? Thanks!

        D Offline
        D Offline
        David Mujica
        wrote on last edited by
        #3

        How is the @Sql1 variable defined ? Ex: Declare @Sql1 Varchar(200)

        1 Reply Last reply
        0
        • U User 11499542

          hi, i have a problem while executing updates using the update script inside the variable, it gives the error "String or binary data would be truncated"; I realized that if reduce the number of fields to update, it no longer gives the error! But I didn't want to divide the execution of the update into 2 variables!!! Can you help? Thanks!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          After thinking about this a bit more than required;

          Member 11533892 wrote:

          But I didn't want to divide the execution of the update into 2 variables!!!

          You mean you don't want to execute two update-statements for the same record. Two variables cost nothing nowadays, so that doesn't make any sense. Two updates must be atomic, or you get concurrency issues. Could be simply solved by using a transaction. You may find the error to be the design of the table, not the update-statement. I'm going to guess a lot of those fields can be "NULL" or revert to some preset default value. ..but, let me give you a solution from a VB6 programmer view; you can rename all columns into numbers. So if column one is named [Name], you replace that with [1]. You can keep a list in Excel to look up the column names. That way, the update-statement is shorted a lot, and a huge lots of them would fit in a VARCHAR(MAX) command. :rolleyes:

          Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups