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 |
|
SanjaySutar
Starting Member
18 Posts |
Posted - 2008-04-04 : 04:56:35
|
| Hi, i have a stored procedure as :----------------------------------------------------------CREATE PROCEDURE Insert_tblAccount @Name varchar(50), @Password varchar(20), @StatusID int, @AccountType int, @DOI datetime, @ROI varchar(500)ASDeclare @NewID Numeric(18)BEGIN SET NOCOUNT ON INSERT INTO [tblAccount](Name, [Password], StatusID,AccountType, DOI, ROI ) VALUES(@Name, @Password, @StatusID, @AccountType, @DOI, @ROI) Set @NewID = SCOPE_IDENTITY() Select @NewID As NewIDEND----------------------------------------------------------------i could not understand the line Select @NewID As NewIDbcoz i have learned that NewId() function returns unique identifierbut above code returns same value as SCOPE_IDENTITY.So can anybody make me clear what's going on ?????thanx in advanceSan |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-04 : 05:07:05
|
| Its just a variable to which the result of SCOPE_IDENTITY is assigned. ANd the statement in bold just selects its value with a alias name NewID. notice that you dont have () after NewID so it is not a function invocation. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-04 : 06:23:20
|
| You should note that Newid is followed by AS. So it is alias nameSelect newid(),newid() as newidMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|