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 |
|
vicpal25
Starting Member
21 Posts |
Posted - 2008-07-23 : 14:22:04
|
| Im bombing on this line:SET @CfIdentity=SELECT @@IDENTITYHow can I pass the identity to a variable? |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-07-23 : 14:26:09
|
| SELECT @CfIdentity = @@IDENTITY |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-07-23 : 14:54:36
|
| Or even better (as @@IDENTITY should be avoided):SET @CfIdentity = SCOPE_IDENTITY()I use SELECT only when dealing with multiple variables.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-24 : 03:01:17
|
quote: Originally posted by vicpal25 Im bombing on this line:SET @CfIdentity=SELECT @@IDENTITYHow can I pass the identity to a variable?
That should beSET @CfIdentity=(SELECT @@IDENTITY)MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-24 : 04:27:10
|
| Refer this for understanding difference b/w @@IDENTITY & SCOPE_IDENTITYhttp://blog.falafel.com/2008/04/23/TSQLTheDifferenceBetweenIdentityScopeidentityAndIdentcurrent.aspx |
 |
|
|
|
|
|