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 2000 Forums
 Transact-SQL (2000)
 Error 443: in rand function

Author  Topic 

sirf_atif
Starting Member

4 Posts

Posted - 2004-11-11 : 09:12:00
i m having a problem wid a stored procedure
i m using RAND function like this

select @rnd = RAND()
but is giving me an error that is
Error 443: Invalid use of 'rand' within a function

what is the solution?

<sirf_atif>

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-11-11 : 09:22:44
udf's must be deterministic -- and of course RAND is non-deterministic, since it returns random numbers!

the solution is a workaround using a view:

create View vRandomNumber
as
select RAND() as RandNumber

once you have that set up, you can just use the view in your UDF:

select @rnd = RandNumber from vRandomNumber


Does this help?


- Jeff
Go to Top of Page

sirf_atif
Starting Member

4 Posts

Posted - 2004-11-22 : 02:56:22
Thanx a lot dear .
actually i had been very busy last days thats y i didnt reply u for thanx
sorry for it
:)

<sirf_atif>
Go to Top of Page
   

- Advertisement -