sql server - Insert data to parent table and child table at thesame time sql -


i'm want insert data parent table child table 1 sql query.

i have 2 tables, users table , userinfo table

users table - parent table

  • user_id - pk
  • username
  • password

userinfo table - child table

  • user_id - fk parent table
  • lastname
  • firstname etc...

i'm using 2 inserts before have same user_id. there way in single query?

you view instead of insert trigger. i'm not saying that's best idea, could. also, wrap in stored procedure pass username, password, first name, last name, etc , proc handle 2 (or more) inserts you.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -