Populate a temporary table with data ordered randomly???
Posted on 2006-04-26
I have a stored procedure. In this stored procedure I have created a temporary table..
...Now I need to populate this temp table with data from another table. BUT I need to randomly order the data before populating the temp table?? Can anyone help with this. My simple stored procedure looks like this:
CREATE PROCEDURE sp_CreateRestTable
CREATE TABLE #temp_tbl_Restaurants (
ImageURL varchar(50) )
INSERT INTO #temp_tbl_Restaurants (RestID, RestName, ImageURL) (SELECT RestID, RestName, ImageURL FROM tbl_Restaurants ORDER BY NEWID() )
Trouble is the insert clause doesn't like the order by part??? Any help would be greatly appreciated!!