Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
may i know how to a value into two tables at a time...

ex:

i'm having radio button male and female..
when i'm clicking the female that value should store in both the tables i.e tfn and pay tables at a time
Posted
Comments
RaisKazi 7-Nov-11 2:32am    
What is a disadvantage or harm you see in saving your record one after another in Tables?

 
Share this answer
 
Your question is unclear, but the way it is I'd give you a warning: don't store the same value in two tables, it'll eventually lead to inconsistent data. Instead, use one dedicated table to store data and reference it in other tables.
 
Share this answer
 
Hi,
You Can Use trigger here .................

1)write trigger in table tfn...
1)once you insert into table tfn.......trigger will get executed and and you can insert that value from tfn to another table.

Refer this for Triggers
Triggers -- Sql Server[^]
 
Share this answer
 
 
Share this answer
 
You can Use triggers,
StoredProcedures,
And transactions
to do this.
but As my friend Timberbird mentioned, dont use same data in two different tables as it reduces the dataIntigrity.. Use transactions if you really wants that..
 
Share this answer
 
By using trigger you can insert value in two table at a time.
I have explained bellow how to use trigger.

Quote:
----------------------------------------
create table Table1(name varchar(50))

create table Table2(name varchar(50))

-----------------------------------------
create trigger insert_data on Table1
for insert
as
begin
declare @name varchar(50)
select @name =name from inserted
insert into Table2(name) values(@name)
end

---------------------------------------------

insert Table1(name) values('Purnananda Behera')

----------------------------------------------------

select * from Table1

select * from Table2
-----------------------------------------------
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900