sql - Insert using stored procedure -


i want insert record multiple tables @ single time using stored procedure. if exists, record not inserted. how can it? need help. have link between tables.

create table [dbo].[tblrole]  (       [roleid]   [int] identity(1, 1) not null,       [rolename] [varchar](50) null,        primary key clustered ([roleid] asc) )  

it's normal cannot insert duplicate record if have unique primary key. have been talking multiple tables, you've schown 1 table definition. i've understood problem, this:

create proc insert_data  -- params coming here if not exists(select 1 your_target_table1 column = @condition)    -- insert comes here else   -- nothing or log en error in error table or update if not exists(select 1 your_target_table2 column = @condition)    -- insert comes here else   -- nothing or log en error in error table or update -- , 

Comments