| Author |
Topic |
|
kasaya
Starting Member
10 Posts |
Posted - 2009-02-17 : 01:26:01
|
| Hi,Can u Help me in this situation....for example : i have 10 records and i have to use each one of them in to update another table... record 1 will update record 1 in other table record 2 will update record 2 in other table.and so on..,what method should i use in programming this situation will look like thisfor each row in record row update set datarow = row..hope u understand my situation ^__^arigato.... |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-17 : 01:34:01
|
| update tabl1set col1 = values-----------from tabl1 t1inner join tabl2 t2 on t2.id = t3.id |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 01:43:18
|
| u can create a stored procedures and then update the fields by passing parameters |
 |
|
|
kasaya
Starting Member
10 Posts |
Posted - 2009-02-17 : 01:53:20
|
| select distinct user from tblUsers...-----and for example the output will look like thisuser1user2user3user4for each output the first query gives there will be an insert statement like thisinsert into tblExistingUser user1insert into tblExistingUser user2insert into tblExistingUser user3insert into tblExistingUser user4the above statements should look like...i cant explain clearly my situation hope you can understand it ^__^arigato... |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 01:57:10
|
| create proc usp_samp(@user varchar(32))set nocount oninsert into tblexistinguser (usernamecol)select @user--if any cond..set nocount off |
 |
|
|
kasaya
Starting Member
10 Posts |
Posted - 2009-02-17 : 01:57:27
|
quote: Originally posted by bklr u can create a stored procedures and then update the fields by passing parameters
hi,yes that is what i am trying to do.. first i will query the distinct value then after that i want to loop in each of the query result and insert it using each of the query result..arigato |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 01:59:34
|
| u will get the datatable for select statementfrom front end pass the each usernamein a while loop and call the sp then u can insert the values in to existinguser tables |
 |
|
|
kasaya
Starting Member
10 Posts |
Posted - 2009-02-17 : 02:01:54
|
quote: Originally posted by bklr u will get the datatable for select statementfrom front end pass the each usernamein a while loop and call the sp then u can insert the values in to existinguser tables
hi,is there a way to do this in the SP'sim trying to avoid many query inside my form to avoid LAG'sarigato |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 02:08:03
|
| u want to update the values in the tblexisting userr insert the record in to tblexistinguserthen directly insert into tblexistinguser (usernamecol)select username from tblusers |
 |
|
|
kasaya
Starting Member
10 Posts |
Posted - 2009-02-17 : 02:12:34
|
quote: Originally posted by bklr u want to update the values in the tblexisting userr insert the record in to tblexistinguserthen directly insert into tblexistinguser (usernamecol)select username from tblusers
hi,i want to insert the user in tblUser into tblExistingUseryes...that's... can you help me on how to do thisarigato |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 02:16:10
|
| try like thisinsert into tblexistinguser (usernamecol)select distinct username from tblusers |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-17 : 03:00:41
|
or did you mean this?insert into tblexistinguser (usernamecol)select distinct t.username from tblusers twhere not exists (select 1 from tblexistinguser where usernamecol= t.username) |
 |
|
|
kasaya
Starting Member
10 Posts |
Posted - 2009-02-19 : 01:49:29
|
quote: Originally posted by visakh16 or did you mean this?insert into tblexistinguser (usernamecol)select distinct t.username from tblusers twhere not exists (select 1 from tblexistinguser where usernamecol= t.username)
hi,thanks this code is very complex in a way that it have many select statements but it works. :D ^_^i used fetch but this code is way better...thanks a lot-kasaya |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-19 : 03:43:21
|
| welcome |
 |
|
|
|