您的位置:首页 > 数据库

SQL 随机函数用法

2006-06-30 17:56 399 查看
/**
作者: William
日期: 2006-06
功能: 通过员工Id 随机获取 员工信息
**/
use Northwind
create proc getInfoByRandNumb
as
declare @theMin int,
@theMax int,
@getRandId int
set @theMin = (select min(employeeid) from employees)
set @theMax = (select max(employeeid) from employees)
set @getRandId = (select cast(@theMax * rand() + @theMin as int))
select * from employees where employeeid = @getRandId

/**************
把employee 表改成 你的"手机"表 试试
****************/

在英文系统中,更改数据表,或显示数据时,有时要加上 N

UPDATE WineList_cn
SET Country = N'南澳'
WHERE (Country = N'澳大利亚')
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: