Solved

return a value after insert data

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server - SQL field is defined as text 3 39
SQL Server stored proc 2 20
Query to return total 6 19
migrate a SQL 2008 to 2016, 2 29
This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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