Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Can any one tell why t-sql not allowing using RAND function in side a function

SELECT  CAST (RAND() * 10000000 as varchar(20))

the error is

Invalid use of a side-effecting operator 'rand' within a function.
share|improve this question
7  
2  
What version of SQL are you using? It works just fine on my SQL Server 2008 R2 instance. –  mrdenny Jan 22 '13 at 22:12
    
we use mssql 2008 enterprise edition –  kumar_2002 Jan 22 '13 at 22:13
1  
can you post the whole function? –  A-K Jan 23 '13 at 1:59
1  
I'm not sure what Denny was trying; I get the same error on my 2008 R2 instance when putting that code in a function definition. –  Jon Seigel Jan 23 '13 at 3:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.