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 |
|
jylland
Starting Member
27 Posts |
Posted - 2010-02-08 : 06:06:40
|
| How can I do this, Every time I put a name to table A the trigger should insert 10 rows in table B, with at range (1-10), the table A's ID and 10 standard Names (See below)I have tried this SQL but here I mised the standard names, here all name is null, but I want to put se 10 standard names (see below)create trigger trg_insert on tableA for insertas insert into tableB ( id, range, name ) select i.id, h.r, null from inserted i cross join ( select 1 r union all select 2 union all select 3 union all select 4 union all select 5 union all select 7 union all select 8 union all select 9 union all select 6 union all select 10 ) hTable AID Name1 Ben2 Hugo Table BID Range Name1 1 Jones1 2 Peter1 3 John1 4 James1 5 Lim1 6 Johny1 7 Lin1 8 Jack1 9 Nick1 10 Poul2 1 Jones2 2 Peter2 3 John2 4 James2 5 Lim2 6 Johnny2 7 Lin2 8 Jack2 9 Nick2 10 Poul |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-08 : 06:17:55
|
[code]select i.id, h.r, h.namefrom inserted icross join ( select 1 r, 'Jones' as [name] union all select 2, 'Peter' union all select 3, 'John' union all . . . ) h[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
jylland
Starting Member
27 Posts |
Posted - 2010-02-08 : 06:34:41
|
| Thanks khtanGreat |
 |
|
|
|
|
|
|
|