Solved

return a value after insert data

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql join/ assign small # first 10 83
Sql query for filter 12 32
BULK LOGGED - log full 9 25
default constraint within a function 3 37
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 Copy Database Wizard 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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

17 Experts available now in Live!

Get 1:1 Help Now