日期:2014-05-17 浏览次数:20480 次
--> 测试 IF OBJECT_ID('pmyStoreProcess') IS NOT NULL DROP PROC pmyStoreProcess GO CREATE PROC pmyStoreProcess @a VARCHAR(10), @b INT, @c INT AS BEGIN SELECT 房间编号=@a+'-'+RIGHT(100+a.number,2)+'-'+RIGHT(100+b.number,2), 楼盘号=@a, 层数=RIGHT(100+a.number,2), 房间号=RIGHT(100+b.number,2) FROM master..spt_values a ,master..spt_values b WHERE a.number BETWEEN 1 AND @b AND b.number BETWEEN 1 AND @c AND a.type='p' AND b.type='p' END go --------------开始查询-------------------------- EXEC pmyStoreProcess 'F1',2,3 ----------------结果---------------------------- /* 房间编号 楼盘号 层数 房间号 F1-01-01 F1 01 01 F1-01-02 F1 01 02 F1-01-03 F1 01 03 F1-02-01 F1 02 01 F1-02-02 F1 02 02 F1-02-03 F1 02 03 */