Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set default value

Status
Not open for further replies.

gambhir

Programmer
Oct 17, 2000
15
US
How do you set a default value in Table2, column 2 so that every time a new row is added to Table2, the last value from Table1, column1 is inserted into Table 2 for that new row just added.

Basically I am need to set the last PK incremented value from Table1, and set it as the default value as the FK for the last row in Table2 so that when I insert a add a row in Table 2 the default value for the record is set.

Thanks guys and gals,

gambhir
 
Could someone give a specific example for a trigger that would accomplish this task? I have not been successful in writing one.
 
isn't easier just to insert the needed value value?
for example

insert into table2(...)
values(a,b,c, (select max(x) from table1))
John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top