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 |
|
sirf_atif
Starting Member
4 Posts |
Posted - 2004-11-11 : 09:12:00
|
| i m having a problem wid a stored procedurei 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 functionwhat 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 vRandomNumberasselect RAND() as RandNumberonce you have that set up, you can just use the view in your UDF:select @rnd = RandNumber from vRandomNumberDoes this help?- Jeff |
 |
|
|
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 thanxsorry for it :)<sirf_atif> |
 |
|
|
|
|
|