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
 General SQL Server Forums
 New to SQL Server Programming
 Finding an alternative to the IDENTITY Function

Author  Topic 

fosterc
Starting Member

3 Posts

Posted - 2009-01-20 : 09:49:22
I've got a Stored Procedure that is working fine using the IDENTITY function, but now need to create a VIEW instead. As I am unable to create temporary tables within the view, is there an alternative function for me to use that does the same as IDENTITY?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2009-01-20 : 09:52:57
Are you using SQL Server 2005?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

fosterc
Starting Member

3 Posts

Posted - 2009-01-20 : 09:54:12
No it's SQL Server 2000
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-20 : 10:29:26
Use Correlated Subquery.
But beware, it will bring your server down to it's knees if the resultset is large.



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-20 : 11:26:24
see method given here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=115162
Go to Top of Page

fosterc
Starting Member

3 Posts

Posted - 2009-01-20 : 11:31:22
Ooh thanks for that - I'll give it a try :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-20 : 11:34:43
welcome
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-20 : 11:46:54
The link refers to SQL Server 2005.



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-20 : 11:51:18
quote:
Originally posted by Peso

The link refers to SQL Server 2005.



E 12°55'05.63"
N 56°04'39.26"



Nope. I have given 2000 solution as well
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-20 : 13:00:17
Oh, you mean the last post regarding correlated subquery?
Which was already mentioned?



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

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2009-01-20 : 14:39:09
You could cheat by create a user-defined table function that uses your Identity logic, and then just have your view select from the function...

________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page
   

- Advertisement -