Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not exactly sure what your mean but this should at least point you in the right direction</p> <pre><code>Begin Try Begin Transaction Update Users Set Users.address = Address.address, create_date = GetDate() From Addresses Inner Join Users On Addresses.userid = Users.userid Commit Transaction End Try Begin Catch Rollback Transaction End Catch </code></pre> <p>It should be something like this. There are a couple of ways of doing the problem so have fun with it and hopefully this helped. For testing it write two <code>Select * From Users</code> statements one before and one after. Also change <code>Commit Transaction</code> to <code>Rollback Transaction</code> so you don't have to worry about making a mistake.</p> <p>Just reread question yea you can't do that in one shot just replace the <code>Update</code> statement with</p> <pre><code>Insert Into Addresses (address_id, create_date, location, user_id) Values ('@ddr355_1d', GetDate(), '1234theLocation', 123478) </code></pre> <p>and you will have to do that for each one but should be easy with only 16 entries in the User table. You might want to look into writing a Stored Procedure if you plan on adding more to the table. Something kind of like this</p> <pre><code>Create Procedure [dbo].[AddressesInsertData] ( @Address Int, @Location varchar(100), @UserId Int ) As Begin Try Begin Transaction Insert Into Addresses (address_id, create_date, location, user_id) Values (@Address, GetDate(), @Location, @UserId) Commit Transaction End Try Begin Catch Rollback Transaction End Catch </code></pre> <p>Basic structure of a stored procedure. I would add an <code>if not exists</code> in there that would update instead of insert but this should be plenty to get you started. Hopefully these examples should clear up somethings for you and help you out.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload