| Author |
Topic |
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 00:44:44
|
| declare @name varchar(500)declare @ids varchar(20)set @ids='U100000000'begin transelect @name=vastname from login where aid = @idsif @name is not nullbeginupdate request123set vasname=@name where vAsid=@idsprint @namecommit tranendelsebeginprint 'Invalid ID'rollback tranendHow to know Update Command is Completeit gives a number , how to store these numbersas0-commit Tran1-Rollback TranI m not sure ...Ved Prakash Jha |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 01:16:39
|
| can you elaborate on what you want? are you trying to return status for update operation? |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 02:18:01
|
| I have to write ID one time if it is true than it will update the tableit gives me output as:(0 row(s) affected)ABCthen plz tell me how I know that Update is successfully or notVed Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 02:32:53
|
quote: Originally posted by vedjha I have to write ID one time if it is true than it will update the tableit gives me output as:(0 row(s) affected)ABCthen plz tell me how I know that Update is successfully or notVed Prakash Jha
what does this return?select vastname from login where aid ='U100000000' |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 02:47:15
|
| select vastname from login where aid ='U100000000'it returns name of IDasABC as it returns ABC then it is to be updated in the another table.Ved Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 02:50:22
|
| and what does this return?select * from request123 where vasname='ABC' and vAsid='U100000000' |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 04:31:16
|
| It will return only one row with whole infoVed Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 04:44:28
|
quote: Originally posted by vedjha It will return only one row with whole infoVed Prakash Jha
do you have any audit columns like datemodified,datecreated etc? |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 04:54:12
|
| nocolumns as:serial,vasid,vasname,vPackage,inoOfSpon,cStatus in request123Ved Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 04:56:34
|
quote: Originally posted by vedjha nocolumns as:serial,vasid,vasname,vPackage,inoOfSpon,cStatus in request123Ved Prakash Jha
anyways if earlier query returned you data then that means you've row existing with updated values. which means update has happened successfully provided you didnt had value ABC in table before. |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 04:59:49
|
| no actually I have data in login tableform there i want retrieve data and update to table request123Ved Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 05:27:08
|
quote: Originally posted by vedjha no actually I have data in login tableform there i want retrieve data and update to table request123Ved Prakash Jha
yup but what we queried now was in request123 which showed data is there meaning update was successful. |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 05:40:59
|
| sorry..... ID takes spaces by which Table does not updatedVed Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 05:46:35
|
quote: Originally posted by vedjha sorry..... ID takes spaces by which Table does not updatedVed Prakash Jha
sorry didnt get what you're telling about. alternatively you can do following alsodeclare @name varchar(500)declare @ids varchar(20)set @ids='U100000000'select @name=vastname from login where aid = @idsupdate request123set vasname=@name where vAsid=@idsselect @@rowcount as 'rows updated' |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-29 : 06:43:15
|
| Thank uVed Prakash Jha |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 06:48:28
|
welcome |
 |
|
|
|