|
Posted by Tony Rogerson on 11/27/05 22:26
You need to use scope_identity(), @@identity is affected by triggers etc...
Tony.
--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"pb648174" <google@webpaul.net> wrote in message
news:1133118993.495847.209820@g47g2000cwa.googlegroups.com...
> After calling the Upload.Save method, loop through the files, saving
> them one at a time. As you save each one, retrieve the @@identity
> property inside the stored proc you are using to insert the new file
> entry. As Celko suggests, You could also use the path and filename as a
> key if you want, since ASPUpload takes care of renaming files if they
> have the same name. Just using an identity column is a heck of alot
> easier though when you have things you want to relate to those files.
>
> Tony Rogerson wrote:
>> Hi,
>>
>> Use SCOPE_IDENTITY() to get the last inserted IDENTITY value for that
>> statement...
>>
>> insert blha......
>>
>> select pkID = SCOPE_IDENTITY()
>>
>> --
>> Tony Rogerson
>> SQL Server MVP
>> http://sqlserverfaq.com - free video tutorials
>>
>>
>> "BigJohnson" <craig.johnson@westleigh.co.uk> wrote in message
>> news:1132937707.195947.101060@g49g2000cwa.googlegroups.com...
>> > We're using ASPUpload as a tool to upload files to our server and save
>> > the details to SQLServer. However, I have an application where I need
>> > to return the pkID of the just saved file. I'm assuming that I could
>> > use the @@Identity command but cannot get this to function.
>> >
>> > Has anyone used this command with ASPUpload with an success, or any
>> > other methods that could be used?
>> >
>> > Thanks.
>> >
>
[Back to original message]
|