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.
| Author |
Topic |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-12-12 : 10:09:09
|
Hi,I've been moving a 2000 database to 2005, all is fine apart from one stored procedure which is as followsset ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[DBAuthenticate]( @username Varchar( 100 ), @password Varchar( 100 ))AsDECLARE @ID INTDECLARE @actualPassword Varchar( 100 )SELECT @ID = IdentityCol, @actualPassword = u_password FROM tblUsers WHERE u_name = @usernameIF @ID IS NOT NULL IF @password = @actualPassword RETURN @ID ELSE RETURN - 2ELSE RETURN - 1 It works fine on the 2000 server, but on 2005 the script gives this error:Invalid column name 'identitycol'I didn't write the SP, can anyone tell what the problem is, there is no column identitycol in tblUsers on either server.Thanks! |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-12 : 10:17:04
|
| Are you sure this SP works in SQL 2000? and that there is no IdentityCol in tblUsers table on SQL 2000 as well? Try running the same SP but prefix table name with dbo. and check whether you get any error in SQL 2000.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-12 : 10:20:47
|
Replace the identitycol alias with the real column name.A stab in the dark would beALTER PROCEDURE dbo.DBAuthenticate( @UserName VARCHAR(100), @Password VARCHAR(100))ASSET NOCOUNT ONDECLARE @ActualPassword VARCHAR(100)SELECT @ID = u_ID, @ActualPassword = u_PasswordFROM tblUsersWHERE u_Name = @UserNameIF @ID IS NULL RETURN -1ELSE IF @Password = @ActualPassword RETURN @ID ELSE RETURN -2 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2007-12-12 : 10:21:03
|
| In SQL 2000, this gets you the Identity Column for that table where as in SQL 2005, this is a reserved word, change IdentityCol to the Identity Column of tblUsers. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-12 : 10:25:23
|
quote: You can refer to the column by using the keyword IDENTITYCOL instead of the proper column name. Because only one column in each table can have the Identity property set, SQL Server always can figure out which column you're referencing.
It seems this functionality is withdrawn on SQL Server 2005. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-12-12 : 10:42:48
|
| Thats great, changing it toSELECT @ID = ID,works fine!Cheers |
 |
|
|
|
|
|
|
|