if your SQL server cannot run Select TOP 10 from table_name
please use :
SET ROWCOUNT 10 will limit the number of rows SQL Server returns to 10.
To turn it off, SET ROWCOUNT 0.
e.g
SET ROWCOUNT 10
select * from lusr_tbl
SET ROWCOUNT 0
Saturday, November 13, 2010
script update data in to same table
below script to update top 5 row a column, into same table:
update tbl_user set user_gift= '99' from (select top 5 user_id from tbl_user ) a where tbl_user.user_id =a.user_id
and below for table:
user_id user_name user_gift
-------- ------------ -------------
1 user01 99
2 user02 99
3 user03 99
4 user04 99
5 user05 99
6 user06 00
7 user07 00
update tbl_user set user_gift= '99' from (select top 5 user_id from tbl_user ) a where tbl_user.user_id =a.user_id
and below for table:
user_id user_name user_gift
-------- ------------ -------------
1 user01 99
2 user02 99
3 user03 99
4 user04 99
5 user05 99
6 user06 00
7 user07 00
Labels:
SQLserver
Subscribe to:
Posts (Atom)