Click here to Skip to main content
14,266,297 members
   

Database

 
QuestionSQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Hotaxion8-Oct-18 21:58
memberHotaxion8-Oct-18 21:58 
AnswerRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Richard Deeming9-Oct-18 2:15
mveRichard Deeming9-Oct-18 2:15 
GeneralRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Hotaxion9-Oct-18 15:20
memberHotaxion9-Oct-18 15:20 
GeneralRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Victor Nijegorodov9-Oct-18 22:03
memberVictor Nijegorodov9-Oct-18 22:03 
GeneralRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Hotaxion14-Oct-18 17:20
memberHotaxion14-Oct-18 17:20 
GeneralRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Richard Deeming10-Oct-18 7:57
mveRichard Deeming10-Oct-18 7:57 
GeneralRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Hotaxion14-Oct-18 17:23
memberHotaxion14-Oct-18 17:23 
AnswerRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
CHill6017-Oct-18 5:05
protectorCHill6017-Oct-18 5:05 
Another technique is to have another table that just generates the ids for you
CREATE TABLE IdsList(id INT IDENTITY(1,1), datum CHAR(1));
-- datum is an arbitrary column 
In your (single) stored procedure first do this
INSERT #IdsList(datum) VALUES('x');
declare @lastnum int  = (SELECT SCOPE_IDENTITY())
I would also suggest putting your stuff into a single SP and wrapping it all up in a transaction
ALTER PROCEDURE [dbo].[sp_HeaderSave] (@Lastnumber int OUTPUT) AS

BEGIN

  BEGIN TRANSACTION [MyTrans]

  BEGIN TRY

    INSERT #IdsList(datum) VALUES('x');
    SET @lastnumber int  = (SELECT SCOPE_IDENTITY())

    INSERT INTO Header (DOCNo, VersionNo, NoteDate)
    VALUES (@Lastnumber,'VersionNo',GETDATE())

    COMMIT TRANSACTION [MyTran]

  END TRY

  BEGIN CATCH

    ROLLBACK TRANSACTION [MyTran]

  END CATCH  
END

GeneralRe: SQL Header Detail Last Number Problem (overlap identity saving Details) Pin
Richard Deeming17-Oct-18 9:04
mveRichard Deeming17-Oct-18 9:04 
QuestionNeed good, easy to manage "mail merge" program, free or not Pin
Charles Wolfe7-Oct-18 21:39
memberCharles Wolfe7-Oct-18 21:39 
AnswerRe: Need good, easy to manage "mail merge" program, free or not Pin
Victor Nijegorodov8-Oct-18 8:32
memberVictor Nijegorodov8-Oct-18 8:32 
GeneralRe: Need good, easy to manage "mail merge" program, free or not Pin
Charles Wolfe9-Oct-18 19:47
memberCharles Wolfe9-Oct-18 19:47 
GeneralRe: Need good, easy to manage "mail merge" program, free or not Pin
CHill6017-Oct-18 8:45
protectorCHill6017-Oct-18 8:45 
QuestionError passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
jkirkerx27-Sep-18 12:41
professionaljkirkerx27-Sep-18 12:41 
AnswerRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
Nathan Minier28-Sep-18 1:19
professionalNathan Minier28-Sep-18 1:19 
GeneralRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
jkirkerx28-Sep-18 8:02
professionaljkirkerx28-Sep-18 8:02 
GeneralRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
jkirkerx28-Sep-18 8:17
professionaljkirkerx28-Sep-18 8:17 
GeneralRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
Nathan Minier28-Sep-18 8:45
professionalNathan Minier28-Sep-18 8:45 
GeneralRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
jkirkerx28-Sep-18 12:18
professionaljkirkerx28-Sep-18 12:18 
AnswerRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
jschell28-Sep-18 11:25
memberjschell28-Sep-18 11:25 
GeneralRe: Error passing MongoDB ObjectID back to .Net Core 2.1 Controller Pin
jkirkerx28-Sep-18 12:44
professionaljkirkerx28-Sep-18 12:44 
AnswerMessage Closed Pin
21-Oct-18 22:40
memberMember 1402786821-Oct-18 22:40 
QuestionRun correctly from code VB.NET Pin
Computechsoft23-Sep-18 22:07
memberComputechsoft23-Sep-18 22:07 
AnswerRe: Run correctly from code VB.NET Pin
Richard MacCutchan23-Sep-18 22:13
protectorRichard MacCutchan23-Sep-18 22:13 
GeneralRe: Run correctly from code VB.NET Pin
Computechsoft23-Sep-18 22:34
memberComputechsoft23-Sep-18 22:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.