I keep getting this error: Any Ideas?
Invalid use of side-effecting or time-dependent operator in ‘newid’ within a function.
I am working with MS-SQL Server 2005. Here is the T-SQL statement:
Create Function [dbo].[GetNewNumber]( )
RETURNS int
AS
BEGIN
Declare @code int
set @code = (SELECT CAST(CAST(newid() AS binary(3)) AS int) )
RETURN (@code)
END
The function will not let you use the NewID, but this can be worked around.
Then you can use
select dbo.[GetNewNumber]()as planned.