Solved

return a value after insert data

Posted on 2010-09-04
4
378 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
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:HainKurt
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 51

Accepted Solution

by:
HainKurt 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now