Solved

return a value after insert data

Posted on 2010-09-04
4
412 Views
Last Modified: 2012-05-10
Hi experts, i have this store procedure
create procedure [dbo].[EvaluacionSentenciasJudicialesInsertar]
(
  @tipoDocumento char(1) ,
      @numeroDocumento varchar(50) ,
...
)
AS
SET NOCOUNT ON
INSERT INTO [EvaluacionSJ].[dbo].[EvaluacionSentenciasJudiciales]
           ([tipoDocumento]
           ,[numeroDocumento]
   ...
     
     VALUES
           (
                                    @tipoDocumento
           ,@numeroDocumento
           ...
           )
I need this sp to return the [numeroDocumento] that this recording in the database (the same command as parameter, but in this case I need to be sent from the table, so that I ensure that the recording was carried out successfully )
0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 55

Expert Comment

by:Huseyin KAHRAMAN
ID: 33605426
try this:

declare @result varchar(50)

select @result = [numeroDocumento] from  [EvaluacionSJ].[dbo].[EvaluacionSentenciasJudiciales]
where [numeroDocumento]=@numeroDocumento

set @numeroDocumento = @result
0
 

Author Comment

by:enrique_aeo
ID: 33605432
but I must declare a return variable?
0
 

Author Comment

by:enrique_aeo
ID: 33605433
or output parameter?
0
 
LVL 55

Accepted Solution

by:
Huseyin KAHRAMAN earned 250 total points
ID: 33605442
put a result output parameter and set it to 0 or 1 depending on the result like

select @result = count(1) from  [EvaluacionSJ].[dbo].[EvaluacionSentenciasJudiciales]
where [numeroDocumento]=@numeroDocumento

so it will be 0 or 1
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question