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'澳大利亚')
作者: 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'澳大利亚')
相关文章推荐
- 【Oracle sql基础】trunc()函数的用法
- SQL语句中in not in exits not exits用法比较
- sql中 with rollup 、with cube、grouping 统计函数用法
- PL/SQL:有关FORALL的用法与FOR,插入记录对比
- SQL集合操作符的用法(Oracle中)
- SQL语句Left join 中On和Where的用法区别
- sql种case语句的用法
- sql之group by的用法
- SQL中CONVERT转化函数的用法
- SQL游标用法(二)
- SAP HANA SQL IFNULL和NULLIF用法与区别
- SQL中Convert转化函数的用法
- SQL STUFF用法
- sql语句中case-when用法
- 3-SQL Union和SQL Union All用法
- 【转】随机函数的rand、srand用法
- 详解SQL Server STUFF的用法
- sql中 substring和charindex 的用法
- SQL中CONVERT转化函数的用法
- Mybatis中动态SQL语句中的parameterType不同数据类型的用法