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

ÓÃSQL´æ´¢¹ý³ÌʵÏÖÅúÁ¿²åÈëÊý¾Ý

ÐÞ¸ÄÄÚÈÝ£ºÉ¾³ýÔ­À´µÄTIMEά¶È£¬Ð½¨TIMEά¶È£¬ÐÞ¸ÄSALESÁ¢·½¡£
Êý¾Ý²åÈ룺
            1£¬ÊÂʵÊý¾Ý²åÈ룺ͨ¹ýDTS¼Óµ÷¶ÈʵÏÖ½«sales_fact_1997µÄÊý¾Ý½øÐи´ÖÆ¡£ÆµÂÊΪÿ·ÖÖÓ10000Ìõ¡£                           
                 Ö÷ÒªÓõ½µÄSQLÓï¾ä£ºselect top 10000 * from sales_fact_1997  
            2,ά¶ÈÊý¾Ý²åÈ룺ͨ¹ýSQLÓï¾ä²åÈëÊý¾Ýµ½time_by_day. ²âÊÔÓõ½µÄSQLÓï¾ä£º
1,µ¥Ìõ²åÈë
INSERT INTO time_by_day
 
(time_id, the_date, the_year, month_of_year, quarter,day_of_month)
VALUES ('1101', '1999-10-1', '1999', '10', 'Q4','1')
2,µ¥Ìõ²åÈë:
INSERT INTO time_by_day
      (time_id, the_date, the_year, month_of_year, quarter, day_of_month)
SELECT TOP 1 time_id + 1 AS time_id, the_date + 1 AS the_date, YEAR(the_date + 1)
      AS the_year, MONTH(the_date + 1) AS month_of_year, { fn QUARTER(the_date + 1)
      } AS quarter, DAY(the_date + 1) AS day_of_month
from time_by_day
ORDER BY time_id DESC
3,Ñ­»·²åÈ룺
DECLARE @MyCounter INT
SET @MyCounter = 0            /*ÉèÖñäÁ¿*/
WHILE (@MyCounter < 2)     /*ÉèÖÃÑ­»·´ÎÊý*/
BEGIN
WAITFOR DELAY '000:00:10'   /*ÑÓ³Ùʱ¼ä10Ãë*/
INSERT INTO time_by_day
      (time_id, the_date, the_year, month_of_year, quarter, day_of_month)
SELECT TOP 1 time_id + 1 AS time_id, the_date + 1 AS the_date, YEAR(the_date + 1)
      AS the_year, MONTH(the_date + 1) AS month_of_year, { fn QUARTER(the_date + 1)
      } AS quarter, DAY(the_date + 1) AS day_of_month
from time_by_day


Ïà¹ØÎĵµ£º

SQL SERVER ͼ±íÊý¾Ý¿â

ͼ±í
ͼ±í(ÓֳƹØϵͼ)ÊÇSQL ServerÖÐÒ»ÀàÌØÊâµÄÊý¾Ý¿â¶ÔÏó£¬ËüÌṩ¸øÓû§Ö±¹ÛµØ¹ÜÀíÊý¾Ý¿â±íµÄ·½·¨¡£Í¨¹ýͼ±í£¬Óû§¿ÉÒÔÖ±¹ÛµØ´´½¨¡¢±à¼­Êý¾Ý¿â±íÖ®¼äµÄ¹Øϵ£¬Ò²¿ÉÒԱ༭±í¼°ÆäÁеÄÊôÐÔ¡£ÀûÓÃÆóÒµ¹ÜÀíÆ÷´´½¨Í¼±íµÄ¾ßÌå²½ÖèÈçÏ£º
(1)ÔÚÆóÒµ¹ÜÀíÆ÷ÖУ¬Õ¹¿ªÖ¸¶¨µÄ·þÎñÆ÷ºÍÊý¾Ý¿â£¬´ò¿ªÒª½¨Á¢µÄͼ±íËùÔÚµÄÊý¾Ý¿â£¬ÓÒ»÷ͼ±íÍ ......

×ܽáSQLite²»Ö§³ÖµÄSQLÓï·¨ÓÐÄÄЩ


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
 
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
 
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0 ......

sql CHARINDEXº¯Êý

sql CHARINDEXº¯Êý
SQL Server 2010-01-15 09:01:15 ÔĶÁ888 ÆÀÂÛ0 ×ֺţº´óÖÐС
CHARINDEXº¯Êý·µ»Ø×Ö·û»òÕß×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖеÄÆðʼλÖá£CHARINDEXº¯Êýµ÷Ó÷½·¨ÈçÏ£º
       CHARINDEX ( expression1 , expression2 [ , start_location ] )
      ......

³õѧPL/SQL Óαê

1,ÏÔʾÓαêµÄ²Ù×÷
  
(1) ¶¨ÒåÓαê
      ¸ù¾Ý²éѯµÄÊý¾ÝÇé¿ö£¬ÔÚPL/SQL¿éµÄÉùÃ÷²¿·Ö¶¨ÒåÓα꣬Ó﷨Ϊ£º
         cursor cursor_name is select_statement;
×¢Ò⣺
     Óαê±ØÐëÔÚPL/SQL¿éµÄÉùÃ÷²¿·Ö½øÐж¨Ò壻 ......

SQL Default Ô¼ÊøµÄ³õ²½ÈÏʶºÍÀí½â£¡

SQL Default Ô¼ÊøµÄ³õ²½ÈÏʶºÍÀí½â£¡
Ê×ÏÈ´´½¨Ò»Õűíhello
CREATE TABLE hello
(
Id_P int PRIMARY KEY,
Firstname varchar(50),
Lastname varchar(50),
Address varchar(50),
City varchar(50)
)
´´½¨Ô¼ÊøÌõ¼þ
CREATE DEFAULT beijing_const AS 'beijing'
°ó¶¨Ô¼ÊøÌõ¼þµ½ÁÐÉÏ
 sp_bindefault beijing_ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ