I tried to write such kind of code as
CREATE PROCEDURE DBO.GENCODE
AS
BEGIN
SELECT NEWID() AS GUID
END
GO
The thing is this procedure doesn’t return a var value so I cannot use it for insert value. So my question is … How to make possible code like
DECLARE @code VARCHAR(MAX)
SET @code = DBO.GENCODE()
INSERT INTO TABLEA(CODE)
VALUES(@code)
And this working snippet as a version…
DECLARE @code VARCHAR(MAX)
SET @code=(SELECT NEWID() AS GUID)
INSERT INTO TABLEA(CODE)
VALUES(@code)
?
Any useful comments are appreciated
As for now I am satisfied with this code because it works fine and gens a random code
But still I hope to get it working as a function. Maybe a little bit later then 🙂