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

CASEÔÚsql serverÖеÄʹÓÃÓ÷¨

CASE Óï¾äÔÚsql server¸úÆäËü³ÌÐòÓïÑÔÖеÄswitch¹¦ÄÜÀàËÆ£¬ÓÃÓÚ¼ÆËãÌõ¼þÁÐ±í²¢·µ»Ø¶à¸ö¿ÉÄܽá¹û±í´ïʽ֮һ¡£
ÔÚsql serverÖÐCASE¾ßÓÐÁ½ÖÖ¸ñʽ£º
a.¼òµ¥ CASE º¯Êý½«Ä³¸ö±í´ïʽÓëÒ»×é¼òµ¥±í´ïʽ½øÐбȽÏÒÔÈ·¶¨½á¹û¡£
b.CASE ËÑË÷º¯Êý¼ÆËãÒ»×é²¼¶û±í´ïʽÒÔÈ·¶¨½á¹û¡£
ÒÔÉÏÁ½ÖÖ¸ñʽ¶¼Ö§³Ö¿ÉÑ¡µÄ ELSE ²ÎÊý¡£
³£¼ûµÄ¼¸ÖÖCASEÓï¾äµÄÓ÷¨ÈçÏÂËùʾ:
   1.CASE º¯ÊýÓÃÓÚ¼ÆËã¶à¸öÌõ¼þ²¢ÎªÃ¿¸öÌõ¼þ·µ»Øµ¥¸öÖµ¡£CASE º¯Êýͨ³£µÄÓÃ;ÊÇʹÓÿɶÁÐÔ¸üÇ¿µÄÖµÌæ»»´úÂë»òËõд¡£
ÏÂÃæµÄ²éѯʹÓà CASE º¯ÊýÖØÃüÃûÊé¼®µÄ·ÖÀ࣬ÒÔʹ֮¸üÒ×Àí½â¡£
USE pubs
SELECT
   CASE type
      WHEN 'popular_comp' THEN 'Popular Computing'
      WHEN 'mod_cook' THEN 'Modern Cooking'
      WHEN 'business' THEN 'Business'
      WHEN 'psychology' THEN 'Psychology'
      WHEN 'trad_cook' THEN 'Traditional Cooking'
      ELSE 'Not yet categorized'
   END AS Category,
CONVERT(varchar(30), title) AS "Shortened Title",
price AS Price
from titles
WHERE price IS NOT NULL
ORDER BY 1
    2.ʹÓôøÓмòµ¥ CASE º¯ÊýºÍ CASE ËÑË÷º¯ÊýµÄ SELECT Óï¾ä
    CASE º¯ÊýµÄÁíÒ»¸öÓÃ;¸øÊý¾Ý·ÖÀà¡£ÏÂÃæµÄ²éѯʹÓà CASE º¯Êý¶Ô¼Û¸ñ·ÖÀà¡£
SELECT
   CASE
      WHEN price IS NULL THEN 'Not yet priced'
      WHEN price < 10 THEN 'Very Reasonable Title'
      WHEN price >= 10 and price < 20 THEN 'Coffee Table Title'
      ELSE 'Expensive book!'
   END AS "Price Category",
CONVERT(varchar(20), title) AS "Shortened Title"
from pubs.dbo.titles
ORDER BY price
    3.ʹÓôøÓÐ SUBSTRING ºÍ SELECT µÄ CASE º¯Êý
ÏÂÃæµÄʾÀýʹÓà CASE ºÍ THEN Éú³ÉÒ»¸öÓйØ×÷Õß¡¢Í¼Êé±êʶºÅºÍÿ¸ö×÷ÕßËùÖøÍ¼ÊéÀàÐ͵ÄÁÐ±í¡£
USE pubs
SELECT SUBSTRING((RTRIM(a.au_fname) + ' '+
   RTRIM(a.au_lname) + ' '), 1, 25) AS Name, a


Ïà¹ØÎĵµ£º

SQL2005ºÍ(Excel |access)Ö®¼äµÄÊý¾Ýµ¼Èëµ¼³ö


Sql´úÂë
--²ÉÓÃSQLÓï¾äʵÏÖsql2005ºÍExcel Êý¾ÝÖ®¼äµÄÊý¾Ýµ¼Èëµ¼³ö£¬ÔÚÍøÉÏÕÒÀ´Ò»--Ï£¬ÊµÏÖ·½·¨ÊÇÕâÑùµÄ£º    
  
  
--Excel---->SQL2005  µ¼È룺    
  
  
select * into useinfo from O ......

SQL SERVER±í¼ä¸´ÖÆÊý¾Ý

Select * into customers from clients
(Êǽ«clients±íÀïµÄ¼Ç¼²åÈëµ½customersÖУ¬ÒªÇó£ºcustomers±í²»´æÔÚ£¬ÒòΪÔÚ²åÈëʱ»á×Ô¶¯´´½¨Ëü£»)
Insert into customers select * from clients
½â£ºInsert into customers select * from clients£©ÒªÇóÄ¿±ê±í£¨customers£©´æÔÚ£¬
ÓÉÓÚÄ¿±ê±íÒѾ­´æÔÚ£¬ËùÒÔÎÒÃdzýÁ˲åÈëÔ´±í£ ......

SQLÓï·¨×ܽá

ÕâÊÇÎÒ±ßѧ±ß×ܽáµÄ£¬×ܹ²»¨ÁËÒ»ÌìÒ»Ò¹µÄʱ¼ä£¬²é×ÊÁϺͿ´ÊÓÆµÍê³ÉµÄ£¬µ«ÎÒ¶Ôµ¥Ðк¯ÊýºÍ¶àÐк¯ÊýûÓÐ×ö¹ý¶àµÄÑо¿£¬ÒòΪÕß¿ÉÒÔ²éÎĵµ¡£»¹ÓоÍÊǶà±í²éѯÑо¿Ò²±È½Ïdz£¬Õâ¿ÉÒÔÔÚÒÔºóÓõ½µÄʱºòÔÚ¾ßÌåÑо¿¡£   »¹ÓоÍÊÇÒªÊìϤÊý¾Ý¿âµÄ²Ù×÷£¬Ôöɾ¸Ä²é£¬ÕâЩ¶¼ÒªÏ൱ÊìÁ·£¬Íü¼ÇʱҪ¼°Ê±¿´±Ê¼Ç¡£
SQL
1....... ......

oracle sql×Ô¶¯µÝÔö

Ò»¡¢É¾³ýÁÐ
ALTER TABLE AA DROP COLUMN  DEP;
ÊÊÓÃÓÚС±í-----Êý¾ÝÁ¿Ð¡µÄʱºò£»
2¡¢ALTER TABLE AA SET UNUSED("DEP") CASCADE CONSTRAINTS;
È»ºóÔÚ¸ºÔØÐ¡µÄʱºò£¬É¾³ý
ALTER TABLE AA DROP UNUSED COLUMNS;
¶þ¡¢Ìí¼ÓÁÐ
ÏȼÓÒ»ÐÂ×Ö¶ÎÔÙ¸³Öµ£º
alter table table_name add mmm  varchar2(10);
update ta ......

SQLÐÔÄܵ÷УÃüÁî

DBCC DROPCLEANBUFFERS  --Çå³ý»º³åÇø£¬±ãÓڶԱȲéѯʱ¼äºÍÐÔÄÜ£¬²»ÊÕ»º´æµÄÓ°Ïì
SET STATISTICS TIME  ON --ÏÔʾ·ÖÎö¡¢±àÒëºÍÖ´Ðи÷Óï¾äËùÐèµÄºÁÃëÊý
sp_spaceused NSDoctorAdvice0705 -- ²é¿´±í¿Õ¼ä´óС
ÎÊÌâÌÖÂÛ£º
ÊÇ·ñÔö¼ÓÒ»¸ö¶ÀÁ¢µÄÎļþ×飬ÓÃÀ´´æ·ÅË÷Òý¡£Ä¿Ç°Êý¾Ý¿âµÄÖ»ÓÐÒ»¸öÎļþ×飬Îļþ·Ç³£´óµÄ»°£¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ