sql²éѯ±íÖÐ×ֶβ»Öظ´
·½·¨Ò»£º
select distinct name from tablename
·½·¨¶þ£º
select min(fid),name,sex from tablename group by name
×ܼƣº
select distinct name from tablename ´ò¿ªÖظ´¼Ç¼µÄµ¥¸ö×Ö¶Î
select * from tablename where fid in(Select min(fid) from tablename group by name)´ò¿ªÖظ´¼Ç¼µÄËùÓÐ×Ö¶ÎÖµ
select * from tablename where name in(select name from tablename group by name having count(name)=1)´ò¿ªÖظ´ÈÎÒâ´ÎÊýµÄËùÓмǼ
Ïà¹ØÎĵµ£º
ÔÚSQL Server Management StudioÖÐÁ¬½Óµ½SQL ServerʵÀýºó£¬»áÏÔʾ“SQL Server ´úÀ픽ڵ㡣Èç¹ûµ±Ç°¸ÃʵÀýµÄAgent·þÎñûÓÐÆô¶¯£¬“SQL Server ´úÀ픺ó±ß¾Í»áÏÔʾ“(ÒѽûÓôúÀí¡¡XP)”¡£“ÒѽûÓôúÀí”´Ó×ÖÃæÉϲ»ÄÑÀí½â£¬ºó±ßµÄ“XP”ÓеãÈÃÈ˷ѽâÁË£¬Õâ¸ö·þÎñ¸úWindo ......
ÔÚSQL ServerÖгöÓÚÊý¾Ý°²È«µÄ¿¼ÂÇ£¬ËùÒÔÐèÒª¶¨Æڵı¸·ÝÊý¾Ý¿â¡£¶ø±¸·ÝÊý¾Ý¿âÒ»°ãÓÖÊÇÔÚÁ賿ʱ¼ä»ù±¾Ã»ÓÐÊý¾Ý¿â²Ù×÷µÄʱºò½øÐУ¬ËùÒÔÎÒÃDz»¿ÉÄÜÒªÇó¹ÜÀíԱÿÌìÊص½ÍíÉÏ1µãÈ¥±¸·ÝÊý¾Ý¿â¡£ÒªÊµÏÖÊý¾Ý¿âµÄ¶¨Ê±×Ô¶¯±¸·Ý£¬×î³£Óõķ½Ê½¾ÍÊÇʹÓÃSQL Server´úÀíÖеÄ×÷Òµ¡£Æô¶¯SQL Server Agent·þÎñ£¬È»ºóÔÚÆäÖÐн¨×÷Òµ£¬×÷ÒµÖÐÌí¼ ......
and exists (select * from sysobjects) //ÅжÏÊÇ·ñÊÇMSSQL and exists(select * from tableName) //ÅжÏij±íÊÇ·ñ´æÔÚ..tableNameΪ±íÃû and 1=(select @@VERSION) //MSSQL°æ±¾ And 1=(select db_name()) //µ±Ç°Êý¾Ý¿âÃû and 1=(select @@servername) //±¾µØ·þÎñÃû and 1=(select IS_SRVROLEMEMBER('sysadmin')) ......