Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 problem with scope_identity

Author  Topic 

ejazzaslam
Starting Member

2 Posts

Posted - 2009-01-14 : 05:02:58
hello, i m use typed dataset and in query builder if i use insert command then query excute successfully , but if i user scope_identity after insert , query not passed with error " must declare @parrameter of insert command"
if i declare that parameters then query excute but i cannnot pass parrameter in the code behind file.
here is my syntax:
INSERT INTO MPS_Avg_Company1
(Company_Avg_Description, ACTIVE, CREATED_BY, CREATION_DATE,
UPDATED_BY, UPDATING_DATE, From_date, To_Date, From_Avg_Rate,
To_Avg_Rate, Staus)
VALUES (@Company_Avg_Description,@ACTIVE,@CREATED_BY,@CREATION_DATE,@UPDATED_BY,@UPDATING_DATE,@From_date,@To_Date,@From_Avg_Rate,@To_Avg_Rate,@Staus)
SELECT scope_identity()

error source: .sqlclintreader
error message: Must declare scalar variable @Company_Avg_Description

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-14 : 05:43:37
Why do you think the problem is with SCOPE_IDENTITY() function, when the error message says it is variable @Company_Avg_Description that is not declared?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-14 : 08:46:52
it seems like you've not declared variable @Company_Avg_Description or you're executing insert out batch in which @Company_Avg_Description is declared
Go to Top of Page
   

- Advertisement -