December 21, 2016 at 9:59 am
Please can you help me in turning the following script into a Stored Procedure, I have just tried doing this but I keep getting errors like I have not declared this and that.
The script generates 3 random numbers from a temp table.
DECLARE@columnNumbers NVARCHAR(10);
DECLARE@T1 TABLE
(
col1 INT NOT NULL
);
INSERT INTO @T1(col1)
VALUES (1), (2),(3), (4), (5), (6), (7), (8),(9), (10), (11), (12)
SET @columnNumbers = (SELECT MIN(col1) FROM @T1)
SELECT TOP (3) * FROM @t1
ORDER BY NEWID()
December 21, 2016 at 10:13 am
I'm guessing you just left out the AS after the CREATE PROCEDURE.
Just add this to the beginning:
CREATE PROCEDURE GenerateRandomNumbers
AS
then it would have your DECLARE statements and everything that follows.
Sue
December 21, 2016 at 11:03 am
patelxx (12/21/2016)
Please can you help me in turning the following script into a Stored Procedure, I have just tried doing this but I keep getting errors like I have not declared this and that.The script generates 3 random numbers from a temp table.
DECLARE@columnNumbers NVARCHAR(10);
DECLARE@T1 TABLE
(
col1 INT NOT NULL
);
INSERT INTO @T1(col1)
VALUES (1), (2),(3), (4), (5), (6), (7), (8),(9), (10), (11), (12)
SET @columnNumbers = (SELECT MIN(col1) FROM @T1)
SELECT TOP (3) * FROM @t1
ORDER BY NEWID()
This is rather strange code 🙂 What is your objective with this proc?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
December 23, 2016 at 10:28 am
Thank you sorted
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply