--创建随机存储过程,根据表名,随机排序原有数据 Create Procedure Pro_Rand(@table_name varchar(100)='' ,@sql_where varchar(1000)= '') as Begin declare @sql varchar(1000); if LTrim(@table_name) is not null begin set @sql = 'select *,ROW_NUMBER() over (order by rand(CAST(NEWID() AS BINARY(16)))) as RandNum from ' + @table_name +' ' + @sql_where +' ;'; exec (@sql) end ELSE BEGIN RAISERROR ('%7.100s',17,1,'存储过程Pro_Rand请求参数为1:表名(不能为空);参数2为:where字句(可以为空),请传入正确的参数!表名称不能为空!'); END End