摘要: 在SQL 2000中写存储过程,总会碰到需要TOP的地方,而一旦碰到TOP,因为没办法把TOP后面的数字作为变量写到预编译的语句中去,在SQL 2000中完全可以使用ROWCOUNT要害字解决这个问题。1、使用ROWCOUNT查询前几行结果。DECLARE @n INTSET @n = 1000SET ROWCOUNT @nSELECT * FROM Table_1这样,查询结果将等同于SELECT TOP 100 FROM Table_12、同样的道理,使用INSERT INTO..SELECT的时候也有效。DECLARE @n INTSET @n = 1000SET ROWCOUNT @n 阅读全文
posted @ 2012-06-28 16:07 静儿~ 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 例子: update work_order set order_state = '1' where line_id = p_line_id and order_state = '0' and order_type = 'DPY' and ORDER_PRIORITY = (select min(ORDER_PRIORITY) from work_order where order_state = '0' and order_type = 'DPY' and LINE_ID = p_line_id and order 阅读全文
posted @ 2012-06-28 16:02 静儿~ 阅读(321) 评论(0) 推荐(0) 编辑