November 21, 2006 at 1:06 pm
I am trying to implement a file management system for images, but also for other data types.
I want to store the files in the file system and store the files information: size, original file name, timestamp of upload, userid, and the address to the files location, as well as other information.
Part of the process requires asigning a unique id. I ran across a t-sql command awhile back and can't remember what it was. essentially it simultanious grabbed a unique identifier from the database and returned it in one call so that it could be used to give the file a unique file name so that it would not overwrite another preexisting file.
Anyone know what the command was or anything that would do similar. I am looking for any kind of resource or documentation.
I appreciate any help!
November 22, 2006 at 6:27 am
You could also execute "SELECT @@IDENTITY" on the connection immediately after the insert to get the unique identifier if it is an identity field.
November 24, 2006 at 4:55 pm
I'd never use @@Identity because it is not scope sensitive and, in the presence of triggers, will surely return an incorrect value. Always use SCOPE_IDENTITY for such a thing.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply