Pass Scope_Identity() Back To The Calling Application

Jul 20, 2005

I'm using an Access2K front end on a SQL Server2K backend.
I use Scope_Identity() in a lot of stored procedures to pass the
newwly inserted record's unique ID to the next select statement in the
same stored procedure.
What I'm wondering is how I can pass the Scope_Identity back to the
calling application.
I'm hoping someone can show me the SP code and the aceess code needed
to accomplish the following:

I insert a new record in a table with a stored procedure. The SP
passes the uniqueID (Scope_Identity) back to MS Access, then MS Access
uses the uniqueID when calling another function...

thanks

View 1 Replies


ADVERTISEMENT

Using @@Identity Or Scope_identity To Pass A Newly Generetad ID

Jun 11, 2007

Hi,
I need to pass the ID of a newly inserted product in my products db to a wizard step so that I can achieve the following:
Wizard Step 1: Enter product details
Wizard Step 2: Choose product image and upload to file system, then write to DB. 
All help is appreciated!
Thanks,
 
Chris
 

View 4 Replies View Related

Calling A SP Within A SP And Back

Aug 24, 2007

I was wondering if there was a way to call a stored procedure within a stored procedure, and after that's done, it goes back where the other stored procedure left off? I was also hoping to return a value also. Thank you.

View 3 Replies View Related

How To Pass A SP Parameters W/o Calling The Sp?

Dec 1, 2003

MY DBA wrote a trigger, that upon hitting the delete button for a payment,
the payment would be transferred to another table and the trigger would
call a sp as well. since the trigger is calling the sp, I should only supply the parameters.

How do you do that w/o calling the procedure?

View 1 Replies View Related

No Way To Pass Identity Back To SqlDataSource?

Mar 13, 2007

Is there no way to pass identity info back through SqlDataSource?  You can only do that with ADO.NET code?
In other words, if I want to run a complex INSERT statement to a table that uses Identity, I can't take that key value back through something like SCOPE_IDENTITY() and use it? 
I know how to do this with ADO code, but I can't figure out how to do it purely with SqlDataSource.  I was hoping to do this without having to write a new Insert statement -- just using the one that's already in the SqlDataSource control.  But there doesn't seem to be any facility for Identity in there.  I tried embedding a separate select statement after the insert statement and a semi-colon, but that didn't seem to do anything.
Thanks!
 

View 5 Replies View Related

Pass Back One Value From UDF Having Found It In A Table

Feb 8, 2007

How do I pass back only one value, such as TotalJobPrice from the tblJobRecords when I know which JobID to Select. All I want is the TotalJobPrice returned from the UDF, not a record from the table. I can write a UDF that will return a table, but I don't know how to get the one field of data from that table of one row that can be returned from a UDF that returns a table. I want to be able to write something like this: @TotalJobPrice = fnTotalJobPrice(@JobID)
Hope that is clear.
Thanks in advance,

View 7 Replies View Related

Pass Back Error Count To Parent Pkg

Aug 29, 2007

I am trying to pass back the number of errors encountered by a child package to the Parent package. I have a script within the child package, which will set the value of the Parent package's variable (ChildErrCount). However, I have no idea how to access the Child package's Errors collection to get a count.

Any ideas? Has someone figured out a way to reference the current package's properties (besides what's available from Dts.* ?

Thanks!

View 11 Replies View Related

How To Pass Values To A Calling Stored Procedure

Nov 17, 2006

Currently i am working in a project of report generation in MS ACCESS.

The tables are in sql server 2000.
I have to write stored proc in ms access.

Illustration:
I am having a stored proc as follows

name: myproc
-------------------
Create procedure my_proc
@f1 char(1),
@f2 char(5)
As
select * from table1 where field1=@f1 and field2=@f2
________________________________________________
and calling proc
name: call_myproc

execute my_proc 'A','2004'

If i am getting the vales of field1/@f1 and field2/@f2 from forms in ms access.

I have to get the values from forms in ms access.

I have to write the calling proc as follows

my_proc [forms]![form_a].[Combo4],[forms]![form_a].[text12]

But ms access throws syntax error.

How is it possible to pass values from ms access FORMS to a calling stored procedure.

I have followed the way of creating and executing the stored procedure as given in the article as follows.
http://www.databasejournal.com/features/msaccess/article.php/10895_3363511_1

As per the given link. They did not give values dynamically.

could you please help me to fix this problem ?

regards,
Krishna

View 1 Replies View Related

Calling A Stored Procedure And Pass Parameter One By One

Aug 24, 2007



Hi,

I need to create a batch process which calls a stored procedure.


Here's the scenario.


I have 3 tables

Theater - TheaterId, TheaterName, Revenues,locationid, stateid
State - StateId, StateName
Location - LocationId, LocationName, StateId


There is a stored procedure spoc_updateTheater that accepts the state and location id and runs a set of sql statements against the theater table. However i want this to run for all the locations in a state one by one. There are some 700 locations in 45 states. How do i pass the location and state id one by one to the stored proc. Can i call this from a commandline or run it as batch process?


vidkshi



View 8 Replies View Related

Calling Stored Procedures From Back End C# Codings In ASP .net Designing

Nov 21, 2007

I writte a stored procedure for username , password ....
How can i call that stored procedure to verify the username & password 
then if both match in the database redirected to next page..? in asp with c#.net back end programming
 

View 2 Replies View Related

Calling The SP From ASP.NET Application

Feb 8, 2008

Hi All,
 
I have problem in calling the SP from ASP.NET application 
 @DefApp nvarchar(255)= '' ,@DefBusFunction nvarchar(255)= '' ,@DefImpact nvarchar(255) = '',AS Begin declare @sql nvarchar(4000)declare @whereClause nvarchar(4000)DECLARE     @return_value intdeclare @sqlWhere nvarchar(4000) select @sql = 'SELECT DefApp, DefBusFunction, DefImpact FROM Def LEFT JOIN ZFunction ON (def.DefApp = ZFunction.App) AND (Def.DefBusFunction = ZFunction.BusFunction)' if @DefImpact <> ''      Set @whereClause = ' where DefImpact '      SET @whereClause = @whereClause + ' = ''' + @DefImpact + '''' set @sqlWhere=@sql + @WhereClauseEXEC @sqlWhereEnd 
and i am calling this SP from my ASP.net application to fill the SSRS report. I have written code in ASP.NET like:
 sqlCmd = new SqlCommand("subbusample", conn);
sqlCmd.CommandType = CommandType.StoredProcedure;sqlCmd.Parameters.Add(new SqlParameter("@DefImpact", SqlDbType.NVarChar, 255, txtValue3.Text.ToString()));
sqlCmd.Parameters.Add(new SqlParameter("@DefBusFunction", SqlDbType.NVarChar, 255, txtValue1.Text.ToString()));
sqlCmd.Parameters.Add(new SqlParameter("@DefApp", SqlDbType.NVarChar, 255, txtValue2.Text.ToString()));
 RptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
RptViewer.ServerReport.ReportServerUrl = new System.Uri("http://servername/ReportServer");RptViewer.ShowParameterPrompts = false;
RptViewer.ServerReport.ReportPath = "/folder name/Subbu_Sample";
 
when i execute it, i am not able to fill the report with data.
 
Please let me know what i am doing wrong.
 
Thanks,
SR.

View 6 Replies View Related

Calling One Application From SQL Server

Mar 30, 2004

Is it possble to automatically call an application when another application makes an INSERT from inside sql server? If its possible - how do I do that?

Thx in advance

/MiZza

View 2 Replies View Related

Calling Stored Procedure From A C Application

Jul 20, 2005

I have an ODBC/C program and I want to call the stored proceduressp_addlogin and sp_adduser in it. Can someone please provide me withsome sample code showing the best way to do this.

View 2 Replies View Related

Calling A SSIS-Package From A COM+-Application

Oct 3, 2007

Hello

I have a SSIS-Package stored in the SQL Server. This package works fine when i execute it from the SQL Server. But if I try to execute the package from a COM+-Application, nothing happens.


Here is my code snipped:

Public Function ExecutePackage €¦
Dim myPackage As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult


'----- Execute the package from SQL Server
myPackage = app.LoadFromSqlServer("\PackageName", "ServerInstance", Nothing, Nothing, Nothing)
pkgResults = myPackage.Execute()
€¦

End Function

In a Windows Forms Application I can execute the package with this code snipped succesfully. Therefor I think that the problem is my COM+-Application.

Can anybody help me?


Thank's

JĆ¼rgen Paulus

View 4 Replies View Related

SSIS Calling An External Application

Apr 3, 2008

Can you put is a call withing a Data Flow that will call an External Application and pass a parameter to that application IE say a command line app and then take the output and assign it to back to the flow as a "column" or whatever for that row... IE I want to take a value push it to an external app and then the output from that app I want to insert it into another field for that row in the new table I am moving the data to.

View 4 Replies View Related

Pass Parameters Into SSIS Package From A Web Application

Nov 13, 2007

Hi all,
 I wish to pass parameter from a dropdownlist in my web application to the SSIS package so as to export the user specified table.
Is using package configuration the right way to do this?
Any advice is appreciated!
 

View 8 Replies View Related

Return A Value From Stored Procedure To Calling Application

Jul 20, 2005

Hi,In SQL Books Online in the section on @@Error it gives the followingexample:-- Execute the INSERT statement.INSERT INTO authors(au_id, au_lname, au_fname, phone, address,city, state, zip, contract) values(@au_id,@au_lname,@au_fname,@phone,@address,@city,@state,@zip,@contract)-- Test the error value.IF @@ERROR <> 0BEGIN-- Return 99 to the calling program to indicate failure.PRINT "An error occurred loading the new author information"RETURN(99)ENDELSEBEGIN-- Return 0 to the calling program to indicate success.PRINT "The new author information has been loaded"RETURN(0)ENDGOHow do I access the value returned by the RETURN statement (i.e. 99 or0) in my asp application that called the stored proc.Sometimes rather than just return an integer signifying success orfailure I've seen examples where the id of the newly added item isreturned on success and perhaps -1 if the operation fails. Theseexamples make use of ouput parameters to achieve this. If theoperation succeeds then then the output parameters value is set to thenew id and this is accessed from the calling application.E.g.IF @@ERROR <> 0BEGIN-- Return -1 to the calling program to indicate failure.PRINT "An error occurred loading the new author information"SELECT @MyOuptputParameter = -1ENDELSEBEGIN-- Return id to the calling program to indicate success.PRINT "The new author information has been loaded"SELECT @MyOuptputParameter = @@IDENTITYENDWhy go to this trouble if you can use the RETURN statement?

View 4 Replies View Related

Application Crashes When Calling To Sql Server Routine

Mar 19, 2008

I have an application that manage an sql srever compact edition database it worked OK until I got the following problem:
Only when debuging the application ("Start Debugging" from visual studio). In the first call to an sql server routine I get an exception "Unspecified error [ sqlceqp30.dll ]"

My code:

this.usersTableAdapter.Fill(this.nessDBDataSet.Users);

The line with the exception:


[global:ystem.Diagnostics.DebuggerNonUserCodeAttribute()]

[global:ystem.ComponentModel.DataObjectMethodAttribute(global:ystem.ComponentModel.DataObjectMethodType.Fill, true)]

public virtual int Fill(NessDBDataSet.UsersDataTable dataTable) {

this.Adapter.SelectCommand = this.CommandCollection[0];

if ((this.ClearBeforeFill == true)) {

dataTable.Clear();

}

int returnValue = this.Adapter.Fill(dataTable); //Here I get the exception

return returnValue;

}

The Exception:

Unspecified error [ sqlceqp30.dll ]

Again if I do "Run Without Debugging" Evrything is working.

Can any one help me with this

Thanks
Ofer

View 2 Replies View Related

Passing Status Back From Command Line Application To SQL Job

Jun 4, 2007

Hi,



I have created a job in SQL Server 2005 in which one of the step executes a .NET console application which is created in .NET to update some status to database before the next step. i need some help in sending some status back to sql job when i come accross any problem in the console application for ex when there is a exception i need to send some status to the job, so the job gets failed permanently. i tried few other methods of updating some temporary status database with this error information and have another intermediate step in the job to check for the status... it worked but i dont like doing it. please let me know if there is any other method to do this.



Thanks in advance

Hariharan

View 5 Replies View Related

401 Unauthorized Access When Calling Report Server From ASP.NET Application

Feb 11, 2008

I receive the following error when i call report server web service from an asp.net application:

"The request failed with HTTP status 401: Unauthorized."



Here are the IIS logs on the reporting services server. When i open IE and browse to the web service i provide my user credentials and i can access the web service just fine. However when i call the web service via my asp.net application it looks like my credentials are not being passed??

Browsing web services via internet explorer.

2008-02-11 21:26:13 W3SVC1836052065 HQSQLDEV1 10.69.21.140 GET /Reports/images/16fold.gif - 8080 triwestdbloom 10.69.21.140 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+WOW64;+SV1;+.NET+CLR+2.0.50727;+.NET+CLR+1.1.4322) 10.69.21.140:8080 200 0 0 15

Call from ASP.NET App

2008-02-11 21:26:13 W3SVC1836052065 HQSQLDEV1 10.69.21.140 GET /Reports/images/16fold.gif - 8080 - 10.69.21.140 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+WOW64;+SV1;+.NET+CLR+2.0.50727;+.NET+CLR+1.1.4322) 10.69.21.140:8080 401 1 0 0

Here is my code:


RSWebService.ReportingService rs = new RSWebService.ReportingService();

rs.Credentials = new System.Net.NetworkCredential(@"triwestdbloom",

"blah", "triwest");



//rs.PreAuthenticate = true;

//Get all folders

RSWebService.CatalogItem[] allItems = rs.ListChildren("/", false);

//Get only folders not hidden to the user.

List<RSWebService.CatalogItem> visibleItems = new List<RSWebService.CatalogItem>();

foreach (RSWebService.CatalogItem item in allItems)

{

Response.Write(item.Name.ToString());

}

Any ideas?

View 2 Replies View Related

How To Get IDENTITY_INSERT Incriment Primary Key ID Roll Back When The Application Fails.

Oct 28, 2007

 My question is how to get IDENTITY_INSERT Incriment Primary Key ID  roll back when the application fails.
Using TransactionScope with single connection in DataObject. I am trying to insert row in two dataTable  using its own tableAdapter (two tableAdapter).
I have Product table with ProductID primary key with incriment identity.  and that ProductID is used to insert row in ProductHistory Table. Lets say Product table has the last ProductID=8 (8 rows) and the next ProductID will be 9.
When I insert row in both table and if the second table insert fails both gets roll back (which is good). but when I insert again another time the Product ID=10 not 9. Is there any way to roll back the ProductID in Product table so when i insert next time it has incriment number instead of gap.

View 8 Replies View Related

Application Crashes When Calling Sql Server Routine In Debug Mode.

Mar 23, 2008

I use Microsof Visual Studio 2005 to write a c# aplication for my compact device (Dell Axim).
I also use Sql Server Compact Edition to handle my database.
Everything worked OK but suddenly I get an exception on the first call to fill command of a table in my database (Any table) This exception is happenning only when I debug the application if i run the application without debug everything is workink OK.
The exception details are :

System.Data.SqlServerCe.SqlCeException was unhandled
Message="Unspecified error [ sqlceqp30.dll ]"
HResult=-2147467259
NativeError=25123
Source="SQL Server Compact Edition ADO.NET Data Provider"
StackTrace:
at System.Data.SqlServerCe.SqlCeConnection.ProcessResults()
at System.Data.SqlServerCe.SqlCeConnection.Open()
at System.Data.SqlServerCe.SqlCeConnection.Open()
at System.Data.Common.DbDataAdapter.QuietOpen()
at System.Data.Common.DbDataAdapter.FillInternal()
at System.Data.Common.DbDataAdapter.Fill()
at System.Data.Common.DbDataAdapter.Fill()
at Ness300.NessDBDataSetTableAdapters.UsersTableAdapter.Fill()
at Ness300.LoginPanel.DoLogin()
at Ness300.LoginPanel.OKButton_Click()
at NL300Controls.BmpButton.L300Button_MouseUp()
at System.Windows.Forms.Control.OnMouseUp()
at System.Windows.Forms.Control.WnProc()
at System.Windows.Forms.ContainerControl.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at Ness300.Program.Main()

I tried to run the application from the mobile device in order to connect to it doing "Attch to running process" from visual studio.
But just running the application on the device with the resgistry value:
HKEY_LOCAL_MACHINESOFTWAREMicrosoft.NETCompactFrameworkManaged DebuggerAttachEnabled
set to 1 caused the crash when I set it back to 0 everything works fine.
It worked for me before I do not know what happened.
Is it a security problem ?

Can any one helpi me with this because this problem do not give me a way to debug my application.

View 3 Replies View Related

4 Layered Web Application For Inserting Data Into A Database Using Sql Server As The Back End And A Web Form As The Front End Using C#

Dec 10, 2005

4 Layered Web Application for Inserting data into a database using sql server as the back end and a web form as the front end using C# .
Can someone provide with code as I am new to this architecture and framework.
Better send email.
Thanks In Advance,
A New Bie

View 1 Replies View Related

Using ReportViewer Controls In A Jsp Application Calling Reporting Services Using Web Services

May 29, 2007

Hi,



I am invoking RS web services to render reports, using Apache Axis to generate stub classes from Reporting Service WSDL.



Please let me know if I can integrate Report Viewer control in the jsp where I am writing the report output. Else do I have to create my own custom tags simulating ReportViewer functionality.

View 4 Replies View Related

Having Difficulty Setting Back Up To Back Up File Wihout Datetime Stamp SQL 2K

Apr 24, 2007

Hello,I'm trying to create a simple back up in the SQL Maintenance Plan that willmake a single back up copy of all database every night at 10 pm. I'd likethe previous nights file to be overwritten, so there will be only a singleback up file for each database (tape back up runs every night, so each daysback up will be saved on tape).Every night the maintenance plan makes a back up of all the databases to anew file with a datetime stamp, meaning the previous nights file stillexists. Even when I check "Remove files older than 22 hours" the previousnights file still exists. Is there any way to create a back up file withoutthe date time stamp so it overwrites the previous nights file?Thanks!Rick

View 5 Replies View Related

Mirroring :: Principal Database Get Role Back After Being Back On Line

May 14, 2015

New to Database Mirroring and I have a question about the Principal database server. I have a Database Mirroring setup configured for High-safety with automatic fail over mode using a witness.

When a fail over occurs because of a lost of communication between the principal and mirror, the mirror server takes on theĀ roll of Principal. When communication is returned to the Principal server, at some point does the database that was the previous Principal database automatically go back to being the Principal server?

View 2 Replies View Related

Reporting Services :: Run Two Reports Back To Back Without Page Eject?

Jun 9, 2015

I need to run two reports each of A5 Size to run back to page and print on single A4 paper means in 1st half Sale bill will be printed and in second half Gate Pass Will Be Printed both report will be on same page and size and shape should be maintained. How to do it.

View 4 Replies View Related

How To Pass Pass The Parameter In SQL Command In SSIS Package

Jul 31, 2006

Hi

   We already used Oracle Datasatage Server the following Query statement for Source and Lookup.here there is parameter maping in the SQl Statement . How can achive in SSIS the Folowing Querystatment?

 

Query 1: (source View Query)
SELECT
V_RDP_GOLD_PRICE.GDR_PRODUCT_ID, V_RDP_GOLD_PRICE.ASSET_TYPE, V_RDP_GOLD_PRICE.PREFERENCE_SEQ, V_RDP_GOLD_PRICE.RDP_PRICE_SOURCE, TO_CHAR(V_RDP_GOLD_PRICE.PRICE_DATE_TIME,'YYYY-MM-DD HH24:MI:SS'), TO_CHAR(V_RDP_GOLD_PRICE.REPORT_DATE,'YYYY-MM-DD HH24:MI:SS'), V_RDP_GOLD_PRICE.SOURCE_SYSTEM_ID
FROM
V_RDP_GOLD_PRICE V_RDP_GOLD_PRICE
WHERE
REPORT_DATE = (select max(report_date) from V_RDP_GOLD_PRICE where source_system_id = 'RM' )



 

Query 2: (look up )

 


SELECT
GDR_PRODUCT_ID,
TO_CHAR(MAX(PRICE_DATE_TIME),'YYYY-MM-DD HH24:MI:SS') ,
TO_CHAR(REPORT_DATE,'YYYY-MM-DD HH24:MI:SS')
FROM
V_RDP_GOLD_PRICE
where
GDR_PRODUCT_ID = :1 and
report_date = TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS')  AND
PRICE_DATE_TIME BETWEEN TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS') - 7) AND TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS')
GROUP BY GDR_PRODUCT_ID, TO_CHAR(REPORT_DATE,'YYYY-MM-DD HH24:MI:SS')



 

please anyone give the sample control flow  and how to pass the parameter?

 

Thanks & regards

Jeyakumar.M

 

View 1 Replies View Related

How Do I Back-up &> Truncate &> Shrink &> Back-up SQL 2000

Jul 20, 2005

Hello,I am hoping you can help me with the following problem; I need to process the following steps every couple of hours in order to keep our Sql 2000 database a small as possible (the transaction log is 5x bigger than the db).1.back-up the entire database2.truncate the log3.shrink the log4.back-up once again.As you may have determined, I am relatively new to managing a sql server database and while I have found multiple articles online about the topics I need to accomplish, I cannot find any actual examples that explain where I input the coded used to accomplish the above-mentioned steps. I do understand the theory behind the steps I just do not know how to accomplish them!If you know of a well-documented tutorial, please point me in the right direction.Regards.

View 2 Replies View Related

Using Scope_identity

Oct 20, 2007

Using scope_identity
I am using SQL2005 and I need to insert a record and return ID. I am using scope_identity() in the stored procedure to return the ID for the record just inserted.
Do you see any problem with this when it comes to multi-user and multi-threaded environment.
 

View 6 Replies View Related

Help On Scope_identity

Jan 3, 2008

Hi, i  need the DiagnosisID from the Diagnosis table to be copied and insert it into DiagnosisID from DiagnosisManagement. I was told to use scope_identity(), but i'm not sure how to implement it. Below is my code behind in vb.net. pls help. Dim cmd1 As New SqlCommand("insert into Diagnosis(TypeID, SeverityID, UniBilateral, PatientID, StaffID) values ('" & typevalue & "','" & severityvalue & "','" & unibivalue & "','" & Session("PatientID") & "','" & Session("StaffID") & "')", conn)        cmd1.ExecuteNonQuery()        Dim i As Integer        For i = 0 To hearingarray.Count - 1            Dim li As New ListItem            li = hearingarray(i)            Dim cmd As New SqlCommand("insert into DiagnosisManagement(ManagementID) values ('" & li.Value & "')", conn)        //i need the DIagnosisID from the Diagnosis table to be copied and insert it into DiagnosisID from DiagnosisManagement here            cmd.ExecuteNonQuery()        Next

View 1 Replies View Related

Using SCOPE_IDENTITY()

May 19, 2008

Hi All,
I'm trying to return the last id entered via the following code, and I'm only getting '0' back.
 1 using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString))
2 {
3 connection.Open();
4 using (SqlCommand command = new SqlCommand("REG_S_CustomerIDFromPhoneNumber", connection))
5 {
6 command.CommandType = CommandType.StoredProcedure;
7 command.Parameters.AddWithValue("@Mobile_Telephone", MobileNumber);
8
9 int test = Convert.ToInt32(command.ExecuteScalar());
10
11 Response.Write(test.ToString());
12
13
14 }
15 } My SP is as follows (I'm trying to use one that's already been written for me) 1 SET QUOTED_IDENTIFIER ON
2 GO
3 SET ANSI_NULLS ON
4 GO
5
6
7
8 ALTER PROCEDURE [dbo].[REG_I_CreateBlankCustomer]
9 @Mobile_Telephone varchar(255),
10 @CustomerID int OUTPUT
11
12 AS
13
14 INSERT INTO Customer (Mobile_Telephone)
15 VALUES (@Mobile_Telephone)
16
17 --SET @CustomerID = @@Identity
18 SELECT SCOPE_IDENTITY();
19
20
21 GO
22 SET QUOTED_IDENTIFIER OFF
23 GO
24 SET ANSI_NULLS ON
25 GO
26
27
28
 

 when I'm running this via Query Analyser, I get the ID returned correctly, however as mentioned when ran via that code above - I get a 0 outputted to me.  What am I doing wrong?
 
Thanks!

View 9 Replies View Related

Where To Put This SCOPE_IDENTITY

Jun 9, 2008

i have such a stored procedure.
 
but i dont know where to put that scope_identity to retrieve a value.
 SELECT SCOPE_IDENTITY() AS [@Car_id]
GO
ALTER procedure [dbo].[insertuser](
@Make nchar(10),
@Model nchar(10),
@SellerID varchar(50),
@MileAge nchar(10),
@Year_Model int,
@Price money,
@Date_added datetime,
@Thumb_ID varchar(50),
@Image_id varchar(50),
@Car_id int
)
AS
INSERT INTO
dbo.tbcar
VALUES(@Make,@Model,@SellerID,@MileAge,@Year_Model,@Price,@Date_added);
 
 
INSERT INTO
dbo.tbimages
values
(@Thumb_ID,@Image_id,@Car_id)

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved