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. Updating related 2 Tables

Updating related 2 Tables

Scheduled Pinned Locked Moved Database
databasesql-servercomhelpannouncement
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.
  • M Offline
    M Offline
    msomar
    wrote on last edited by
    #1

    I could execute the following sql in SMSS, but when adding it in a sqldatasource as an update statement, it gets an error. In SSMS, and it works fine:

    UPDATE S
    SET S.DailyBudget = 12
    FROM Account O INNER JOIN AdCampaign S
    ON O.ID = S.AccountID
    WHERE O.EmailAddress = 'abc@abc.com'

    But In Sqdatasource, it gets error:

    UPDATE S SET S.DailyBudget = 12 FROM Account O INNER JOIN AdCampaign S ON O.ID = S.AccountID WHERE (O.EmailAddress = @EmailAddress)

    Error: Invalid Object Name 'S'. Hint: S,O are borrowed names, and not actual table names.

    S 1 Reply Last reply
    0
    • M msomar

      I could execute the following sql in SMSS, but when adding it in a sqldatasource as an update statement, it gets an error. In SSMS, and it works fine:

      UPDATE S
      SET S.DailyBudget = 12
      FROM Account O INNER JOIN AdCampaign S
      ON O.ID = S.AccountID
      WHERE O.EmailAddress = 'abc@abc.com'

      But In Sqdatasource, it gets error:

      UPDATE S SET S.DailyBudget = 12 FROM Account O INNER JOIN AdCampaign S ON O.ID = S.AccountID WHERE (O.EmailAddress = @EmailAddress)

      Error: Invalid Object Name 'S'. Hint: S,O are borrowed names, and not actual table names.

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, the hint-text gives you the information why the update failed. SqlDataSource does not provide support for abbreviations. So you have to rewrite your query to

      UPDATE AdCampaign SET AdCampaign.DailyBudget = 12 FROM Account INNER JOIN AdCampaign ON Account.ID = AdCampaign.AccountID WHERE (Account.EmailAddress = @EmailAddress)

      This should work. Regards, Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      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