Solved

Trying to use an insert into statement with a stored procedure plus an additional variable

Posted on 2008-10-20
5
148 Views
Last Modified: 2012-05-05
My code currently is writing to a table in a stored procedure.  The stored procedure should call another stored procedure that then makes a single line of output, however the current stored procedure draws additional data not used in the second stored procedure which I also want to include in the write.

Below is a code snippet, here I use the insert into statement with the stored procedure.  This part works, however I wish to add on to the end of that line a single variable value.  

Any help on how to get that variable put on the end would help.  Note that I can't merely use an update to do it because there isn't a uid, or rather, the uid would be this variable I'm trying to add.

Thanks.
insert into tat_output exec sp_findtesttatcert @mindate,@maxdate,@currenttime,@currentdate,@orderdet,@ordertest,@testsite,@orderloc,@orderphy,@orderpri,@timedatetype,@pattype,@clientcode

Open in new window

0
Comment
Question by:UnderSeven
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
randy_knight earned 250 total points
Comment Utility
what is the primary key of tat_output?  if it is an identity column you could use SCOPE_IDENTITY() to get the PK of the row you just added, then update it.  
0
 

Author Comment

by:UnderSeven
Comment Utility
The problem I'm having here is that a unique primary key isn't generated from the stored procedure that writes most of the data into the tat_output table.  This is because the queries run on that could return a lot of identical results.  There is nothing unique coming from the stored procedure into Tat_output.  Could I use something like an autonumber column with scope_identity() ?
0
 
LVL 4

Expert Comment

by:randy_knight
Comment Utility
Every table should have a primary key, even if it is just a surrogate key that is not real business data.  

And yes, an Autonumber/Identity column would solve your problem.  
0
 

Author Comment

by:UnderSeven
Comment Utility
Thanks I'll give this a try.
0
 

Author Closing Comment

by:UnderSeven
Comment Utility
Yep, this worked perfect.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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.
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

13 Experts available now in Live!

Get 1:1 Help Now