Click here to Skip to main content
15,885,278 members
Home / Discussions / Database
   

Database

 
AnswerRe: "Connecting to sql server files" error Pin
dan!sh 22-Apr-10 5:03
professional dan!sh 22-Apr-10 5:03 
GeneralRe: "Connecting to sql server files" error Pin
Luc Pattyn22-Apr-10 5:30
sitebuilderLuc Pattyn22-Apr-10 5:30 
GeneralRe: "Connecting to sql server files" error Pin
dan!sh 22-Apr-10 8:55
professional dan!sh 22-Apr-10 8:55 
GeneralRe: "Connecting to sql server files" error Pin
Luc Pattyn22-Apr-10 9:04
sitebuilderLuc Pattyn22-Apr-10 9:04 
Questionstoring only single value in primary key table and storing multiple values in foreign key table Pin
developerit21-Apr-10 4:06
developerit21-Apr-10 4:06 
AnswerRe: storing only single value in primary key table and storing multiple values in foreign key table Pin
Corporal Agarn21-Apr-10 4:41
professionalCorporal Agarn21-Apr-10 4:41 
AnswerRe: storing only single value in primary key table and storing multiple values in foreign key table Pin
Ashfield21-Apr-10 5:21
Ashfield21-Apr-10 5:21 
QuestionReturning 2 output parameters in Stored Procedure Pin
Dayekh21-Apr-10 1:17
Dayekh21-Apr-10 1:17 
Hi guys,

I'm trying to get 2 values from a stored procedure: one telling me the execution was successful and another for telling me what the newly inserted ROW ID is. I currently have the following:

<br />
<br />
USE [xyz]<br />
GO<br />
SET ANSI_NULLS ON<br />
GO<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
<br />
ALTER PROCEDURE [dbo].[spName]<br />
	(<br />
		@vchName VarChar (50),<br />
		@intSuccess Numeric(9) OUT<br />
	)<br />
AS<br />
	SET XACT_ABORT ON<br />
	BEGIN TRANSACTION <br />
<br />
	INSERT INTO Table<br />
	(<br />
		vchName <br />
	)<br />
	VALUES<br />
	(<br />
		@vchName<br />
	)<br />
	<br />
	IF   @@ERROR <> 0<br />
		BEGIN<br />
			SELECT @intSuccess = 0<br />
			ROLLBACK<br />
		END<br />
	ELSE<br />
		SELECT @intSuccess = 1 <br />
<br />
	/* SET NOCOUNT ON */ <br />
COMMIT TRANSACTION<br />
SET XACT_ABORT OFF<br />
<br />
RETURN @intSuccess<br />
<br />


Currently it returns the value "@intSuccess" ONLY. I want to add the line "SELECT @@IDENTITY AS inLatestID" right under the insert statement so I can get the latest ID value of the record that was just newly inserted.

I think I will need to return another value alongside @intSuccess, but I'm not sure how that works in the Stored Procedure
AnswerRe: Returning 2 output parameters in Stored Procedure Pin
Ashfield21-Apr-10 2:36
Ashfield21-Apr-10 2:36 
GeneralRe: Returning 2 output parameters in Stored Procedure Pin
Dayekh21-Apr-10 4:15
Dayekh21-Apr-10 4:15 
GeneralRe: Returning 2 output parameters in Stored Procedure Pin
Ashfield21-Apr-10 5:19
Ashfield21-Apr-10 5:19 
QuestionGoofy Question About SQL Server Pin
Roger Wright20-Apr-10 16:26
professionalRoger Wright20-Apr-10 16:26 
AnswerRe: Goofy Question About SQL Server Pin
Luc Pattyn20-Apr-10 16:50
sitebuilderLuc Pattyn20-Apr-10 16:50 
JokeRe: Goofy Question About SQL Server Pin
Mycroft Holmes20-Apr-10 16:53
professionalMycroft Holmes20-Apr-10 16:53 
GeneralRe: Goofy Question About SQL Server Pin
Roger Wright22-Apr-10 14:47
professionalRoger Wright22-Apr-10 14:47 
AnswerRe: Goofy Question About SQL Server Pin
Mycroft Holmes20-Apr-10 16:51
professionalMycroft Holmes20-Apr-10 16:51 
GeneralRe: Goofy Question About SQL Server Pin
Luc Pattyn20-Apr-10 16:58
sitebuilderLuc Pattyn20-Apr-10 16:58 
AnswerRe: Goofy Question About SQL Server Pin
Johan Hakkesteegt20-Apr-10 20:06
Johan Hakkesteegt20-Apr-10 20:06 
GeneralRe: Goofy Question About SQL Server Pin
Roger Wright22-Apr-10 14:48
professionalRoger Wright22-Apr-10 14:48 
AnswerRe: Goofy Question About SQL Server Pin
PIEBALDconsult21-Apr-10 4:39
mvePIEBALDconsult21-Apr-10 4:39 
GeneralRe: Goofy Question About SQL Server Pin
Roger Wright22-Apr-10 14:50
professionalRoger Wright22-Apr-10 14:50 
GeneralRe: Goofy Question About SQL Server Pin
Johan Hakkesteegt22-Apr-10 21:59
Johan Hakkesteegt22-Apr-10 21:59 
QuestionSQL Group by and Sum () Pin
I Believe In GOD20-Apr-10 7:37
I Believe In GOD20-Apr-10 7:37 
AnswerRe: SQL Group by and Sum () Pin
Stryder_120-Apr-10 8:18
Stryder_120-Apr-10 8:18 
GeneralRe: SQL Group by and Sum () Pin
I Believe In GOD20-Apr-10 10:03
I Believe In GOD20-Apr-10 10:03 

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.