Invalid use of a side-effecting operator "newid" within a function.

Unfortunately you can not use the NEWID() funtion within a SQL Server funtion. One brilliant solution to this case is to use a predefined view with

create view v_getNewID as select newid() as new_id , 0 as tmp 
go

select top 16 number as n from master..spt_values
where
            type='p'
order by (SELECT [New_Id] FROM v_GetNewID)
go

In my case i used this script to randomly generate Password within  sql server
Tags
Comments
Write the first comment
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (7 + 9) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 03.01.2009
Views: 480
Item date: 10.04.2009
Views: 1025
Item date: 19.07.2009
Views: 706
Item date: 13.05.2009
Views: 1047
Item date: 27.09.2009
Views: 1281
Item date: 06.08.2009
Views: 10031
Item date: 02.01.2009
Views: 1370
Item date: 13.05.2009
Views: 2211
Item date: 03.01.2009
Views: 2102