Since the NEWID() function is a non-deterministic function, this function cannot be called directly from a user-defined function. One way to work around this limitation is to call the function indirectly through a view.

First create a view that calls the NEWID() function:

CREATE VIEW [dbo].[Random]
AS
SELECT NEWID() AS [RandomID]

Since a view can be accessed from a user-defined function, a function can now be created that will indirectly call the NEWID() function through the view: