September 27, 2005 at 11:19 pm
Hii all.,
Please tell me how to use following statementin SQLServer used in sql database
INSERT OR REPLACE INTO table .(table will have primary keys)
I just want insert row if row does not exist with the primary key else i want to update with new values .
Thanks in advance
Regards.,
Sri
September 28, 2005 at 12:49 am
You must create 2 statement for insert and update (if you're in query analyzer).
this for insert and the Table have a sam structure :
insert into table a (select * from table_b where b.primary_key not in (select primary_key from table_b))
For update you must define what column to be updated
September 28, 2005 at 3:32 am
Hii Deni ,
Thanks for ur reply.
As u told i have implemented earlier by using
select statement to find whether the row is present earlier.
Based on reultset of select query I perform update or insert new row.
My requirement is to insert row if it is not present else
update new data values in the table without using using select statement or if used update and insert should be completed in single statement and not two statement oe for update and other update .
I want a short cut like insert or replace statement whick is
present some other SQL based DB .
regards.,
Sri
September 28, 2005 at 3:41 am
SQL Server cannot execute the statement like that (create or replace), that's why i suggest to create 2 statement.
If you want to simplefied that, trying to use stored procedure.
September 28, 2005 at 3:49 am
hi Deni ,
Ok. I will try it out using stored procedures.
Thanks for ur valuble replies
Regards.,
Sri
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply