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 |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2008-02-13 : 21:03:30
|
| Hello,I usually let my SQL table to generate the ID (Guid) of a new record.However, I am having a situation where I need to know the Guid before I insert the record.Is there any disadvantage of sending the ID (Guid) as a parameter instead of letting the SQL table to generate it?And is this usually done? Thanks,Miguel |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-14 : 01:02:09
|
| You could still get the generated GUID before insertion using a INSTEAD OF INSERT trigger. may i know what your scenario is? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-14 : 04:15:27
|
| <<You could still get the generated GUID before insertion using a INSTEAD OF INSERT trigger>>orDECLARE @guid uniqueidentifierset @guid =NEWID()and use this @guid for your manipulationMadhivananFailing to plan is Planning to fail |
 |
|
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2008-02-14 : 07:45:25
|
| Hello,Basically I am now using LINQ instead of a Stored Procedure.I have a form so the user uploads a file and its info to a server.I am using the LinqDataSource which have 2 events: Inserting and InsertedThe sequence is: Inserting Event 1. Upload file to temporary folder 2. If file was uploaded then insert data into the database Inserted Event 1. Rename file in temporary folder. The filename will be the same as the record ID (Guid) 2. Move file to documents folder 3. Update path column in files table. This is the problem. I need to access the database again. But if I would have the ID in Inserting Event then the file would be renamed in the temporary folder. So on the Inserted event I wouldn't need to update the path.Anyway, I am just figuring this out ...Basically, the objective is to upload the file with the Guid as filename, insert the record and if any of these tasks goes wrong to clean everything.Any advice?Thanks,Miguel |
 |
|
|
|
|
|