February 18th, 2003, 01:46 PM
One way to do this in your stored proc is to create a temporary table in your stored proc and make one column as an identity column. Then you can insert rows into the temp table and then select from it.
-- Create the temp table
CREATE TABLE #temp (
id INTEGER IDENTITY(1,1),
-- Insert rows into the temp table
INSERT INTO #temp (
-- Return the rows that were selected into the temp table
SELECT * FROM #temp
-- Drop the temp table before quitting the stored proc.
DROP TABLE #temp
Another way to do this:
SELECT DISTINCT newid(), rest of columns
The newid() function will return unique GUIDs. Depending on what you want, you can use either way.