Solved

return a value after insert data

Posted on 2010-09-04
4
407 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 53

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 53

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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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