Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mohan123
Constraint Violating Yak Guru
252 Posts |
Posted - 2013-01-03 : 08:04:44
|
i have a table A in which data look like this userid documentid name1 1 mohan1 2 raj1 3 majuu2 1 raj2 2 jey2 3 lolso we can observe user id 1 have 3 document id(1,2,3) so how to insert 4 and 5 records when userID 1 have 3 records if it have 3 rd record inserted simultaneously 4 and 5 th record should inserted through procedure can any one suggest me ???P.V.P.MOhan |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2013-01-03 : 08:27:43
|
How are the rows inserted?Do you mean if there is an insert for a user id that has 2 roes then you want an extra two added?Obvious options are Insert via a stored procedure, count the rows then insert the extra 2 if there are 3 rows. It will need to be in a transaction.Create a trigger for insert. If the count is 3 for the user then add the extra 2 rows.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|