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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. update item_guid based on item_code

update item_guid based on item_code

Scheduled Pinned Locked Moved Database
announcement
2 Posts 2 Posters 0 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.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    I am inserting different records using this this:

    INSERT INTO prices (created_user, price_level_id, item_hour, item_category, item_code, item_description, item_price) SELECT @created_user, @price_level_identity, 0, item_category, item_code, item_description, item_price FROM prices WHERE price_level_id = @price_level_id AND item_hour = 0
    INSERT INTO prices (created_user, price_level_id, item_hour, item_category, item_code, item_description, item_price) SELECT @created_user, @price_level_identity, 1, item_category, item_code, item_description, item_price FROM prices WHERE price_level_id = @price_level_id AND item_hour = 1
    INSERT INTO prices (created_user, price_level_id, item_hour, item_category, item_code, item_description, item_price) SELECT @created_user, @price_level_identity, 2, item_category, item_code, item_description, item_price FROM prices WHERE price_level_id = @price_level_id AND item_hour = 2

    I want after that to update the item_guid so all records having the same item_code should have the same item_guid, something like:

    UPDATE prices SET item_guid = ONE_GUID_FOR-ALL where item_code = SAME_ITEM_CODE and price_level_id = WHAT_VER_ID_i_PASS

    R 1 Reply Last reply
    0
    • J Jassim Rahma

      I am inserting different records using this this:

      INSERT INTO prices (created_user, price_level_id, item_hour, item_category, item_code, item_description, item_price) SELECT @created_user, @price_level_identity, 0, item_category, item_code, item_description, item_price FROM prices WHERE price_level_id = @price_level_id AND item_hour = 0
      INSERT INTO prices (created_user, price_level_id, item_hour, item_category, item_code, item_description, item_price) SELECT @created_user, @price_level_identity, 1, item_category, item_code, item_description, item_price FROM prices WHERE price_level_id = @price_level_id AND item_hour = 1
      INSERT INTO prices (created_user, price_level_id, item_hour, item_category, item_code, item_description, item_price) SELECT @created_user, @price_level_identity, 2, item_category, item_code, item_description, item_price FROM prices WHERE price_level_id = @price_level_id AND item_hour = 2

      I want after that to update the item_guid so all records having the same item_code should have the same item_guid, something like:

      UPDATE prices SET item_guid = ONE_GUID_FOR-ALL where item_code = SAME_ITEM_CODE and price_level_id = WHAT_VER_ID_i_PASS

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      Try this:

      declare @Guid uniqueidentifier
      select @Guid = newid()

      update prices set item_guid = @Guid ... rest of code....

      Tychotics: take us back to the moon "Life, for ever dying to be born afresh, for ever young and eager, will presently stand upon this earth as upon a footstool, and stretch out its realm amidst the stars." H. G. Wells

      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