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 |
peterwilson
Starting Member
15 Posts |
Posted - 2008-07-07 : 04:49:00
|
hi friends ,i am having around 10000 no of records in my database , but i dont know how to find the current record get inserted so help me for de same .thankx ` |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-07 : 04:51:57
|
use SCOPE_IDENTITY to get the id generated now and use it to retrive current record if you have an identity field. if you are inserting multiple records and want all of them which are currently inserted you can get them inside a trigger from inserted table. please specify what you exact scenario is. |
 |
|
peterwilson
Starting Member
15 Posts |
Posted - 2008-07-07 : 05:11:22
|
see Visakh ..i m having database name Stud k,in that i m having around 15 table , one reg. done it will insert record into multiple tables like stud_reg and Stud_satus stud_fees like etc.ok so i have to check which is the current record get inserted u r right , but wht happen in this case if i dnt have the Identity field ..and wht sort of Trigger i can use , plz explain me with ex.thankx in advance |
 |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-07-07 : 05:25:26
|
I guess it must be exam time again.http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=106122 |
 |
|
peterwilson
Starting Member
15 Posts |
Posted - 2008-07-07 : 05:37:00
|
ok Rick its seems to be easy...that mean i have to add manually SCOPE_IDENTITY()so it will show the lastst record from table |
 |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-07-07 : 05:44:27
|
What do you mean, "add manually"?!?Here is an example of how scope_identity() will work and what to watch out for. You need to store the value to a variable and then use this value to insert into the second table.declare @test table (a int identity(1,1), b char(1))insert into @testselect 'a'select Scope_identity()insert into @testselect 'b'union select 'c'select Scope_identity() |
 |
|
|
|
|