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
 SQL Server Development (2000)
 User Defined Functions

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-07 : 09:58:15
Aruna writes "I created a user defined function to generate random passwords in which I used the "rand()" built-in function. I got the error "Invalid use of rand within a function". Can anyone help?"

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-05-07 : 10:32:52
Built-in functions that can return different data on each call are not allowed in user-defined functions. This includes RAND, getdate, @@CONNECTIONS. Look for help in BOL (Index: user-defined functions)

The SQL statements inside your scalar-valued functions cannot include
any nondeterministic system functions. Try passing RAND() has a parameter.

select dbo.myPassword(RAND(8))
Go to Top of Page
   

- Advertisement -