Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚSQL Server ɾ³ýÖØ¸´Êý¾Ý

ɾ³ýÊý¾Ý¿â±íÖÐijһ×ֶεÄÖØ¸´¼Í¼£¬Ö»Ïë±£ÁôÒ»Ìõ¼Ç¼¿ÉÓÃÒÔÏ·½·¨£º
Ö´ÐÐÒÔÏÂÓï¾ä£º
declare @max integer,@id varchar(18) --´Ë´¦±äÁ¿ÀàÐ͸ù¾Ý×Ö¶ÎÀàÐÍÉèÖÃ
declare cur_rows cursor local for select ×Ö¶Î,count(*) from ±íÃûgroup by ×Ö¶Î having count(*) > 1
open cur_rows
fetch cur_rows into @id,@max
while @@fetch_status=0
begin
 select @max = @max -1
 set rowcount @max
 delete from ±íÃûwhere ×Ö¶Î = @id
 fetch cur_rows into @id,@max
end
close cur_rows
set rowcount 0


Ïà¹ØÎĵµ£º

SQL ¶à±íÁªºÏ²éѯ

ºÜÉÙÓÃjoin£¬Õâ´Îѧѧ£¬²¢±¸ÍüÁ½ÆªÎÄÕ£¡
ת×Ô£ºhttp://hcx-2008.javaeye.com/blog/285661
Á¬½Ó²éѯ
ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØÏµÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌØµã£¬Ò²ÊÇËüÇø±ðÓÚÆäËüÀàÐÍÊý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØÏµÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹ØÏµ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚÒ ......

SQL Óï¾äΪ±íÔö¼Ó,ÐÞ¸Ä,ɾ³ýÁÐ

1.ÐÞ¸ÄÁÐ
    EXEC sp_rename 'TableName.ColumnName','NewColumName'
2.Ôö¼ÓÁÐ
    ALTER TABLE TableName ADD ColumnName int  --Type In Here
3.ɾ³ýÁÐ
    ALTER TABLE TableName DROP Column ColumnName ......

¾­µäSQLÓï¾ä´óÈ«

Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ëµ ......

»ùÓÚSQLµÄ·ÖÒ³

select top PageSize * from ±í
where Ìõ¼þ and id not in
(select top PageSize*(CurrentPageIndex-1)  id from ±í where Ìõ¼þ order by ÅÅÐòÌõ¼þ)
order by ÅÅÐòÌõ¼þ
¡¶PageSize ÊÇGridViewÖÐÿҳÏÔʾµÄÐÅÏ¢ÌõÊý£¬PageSize*(CurrentPageIndex-1) ÔÚSQLÖв»Ê¶±ð£¬Ð趨Òå±äÁ¿À´Ìæ»»¡· ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ