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

ÇósqlÓï¾ä

×Ö¶Îaa,¹²ÓÐ178¸öÊý¾Ý,ÏÔʾʱÊÇÒ»ÁÐÖ±ÅÅÏÂÀ´µÄ,ÎÒÏëÈÃÕâ178¸öÊý¾Ý,ÿÁÐÖ»ÏÔʾ5¸ö,¶àÁÐÏÔʾÍê,ÈçºÎʵÏÖ?

¼ÓÒ»¸öIDENTITYTÁÐ,°´ID%5À´·Ö

ÒýÓÃ
¼ÓÒ»¸öIDENTITYTÁÐ,°´ID%5À´·Ö

ID-1/5À´·Ö



SQL code:
IF OBJECT_ID('TB') IS NOT NULL DROP TABLE TB
IF OBJECT_ID('TEMPDB..#') IS NOT NULL DROP TABLE #
GO
CREATE TABLE TB(VAL VARCHAR(50))
INSERT INTO TB
SELECT 'A' UNION ALL
SELECT 'B' UNION ALL
SELECT 'C' UNION ALL
SELECT 'D' UNION ALL
SELECT 'E' UNION ALL
SELECT 'F' UNION ALL
SELECT 'G' UNION ALL
SELECT 'H' UNION ALL
SELECT 'I' UNION ALL
SELECT 'J' UNION ALL
SELECT 'K' UNION ALL
SELECT 'L' UNION ALL
SELECT 'M' UNION ALL
SELECT 'N'

SELECT IDENTITY(INT,0,1) 'ID',VAL INTO # from TB

SELECT
MAX(CASE WHEN ID%5=0 THEN VAL ELSE NULL END)
,MAX(CASE WHEN ID%5=1 THEN VAL ELSE NULL END)
,MAX(CASE WHEN ID%5=2 THEN VAL ELSE NULL END)
,MAX(CASE WHEN ID%5=3 THEN VAL ELSE NULL END)
,MAX(CASE WHEN ID%5=4 THEN VAL ELSE NULL END)
from #
GROUP BY ID/5

/*
A B C D E
F G H I J
K L M N NULL
*/


SQL code:
create table tb(id int, data int)
insert into tb values(1 , 1)
insert into tb values(2 , 2)
insert into tb values(3


Ïà¹ØÎÊ´ð£º

ÓÐÈËÓùýsql server2005 ´´½¨·¢²¼Âð£¿

¾ÍÊÇÕ¹¿ªreplication ÓÒ¼üµ¥»÷ local Subscription ´´½¨·¢²¼£¬ ÓÐÈËÓùýÂ𣬳ɹ¦´´½¨·¢²¼µÄÓÐÂð£¿
Óùý£¬¿ÉÒԳɹ¦

ÒýÓÃ
Óùý£¬¿ÉÒԳɹ¦

Ã×ÓùýµÄ°ï¶¥

ÒýÓÃ
Óùý£¬¿ÉÒԳɹ¦

µÚÒ»²½ÎҾ͹ý² ......

ÇósqlÓï¾ä½«Êý¾Ý¿â±íijЩ×ֶεÄÄÚÈÝ·­10±¶

Êý¾Ý¿âij±í£¬Ï뽫ÆäÖÐf1,f2Á½¸ö×ֶεÄÄÚÈÝ·­10±¶£¬Çë½ÌÈçºÎд·¨£¿
update tbl set f1= f1*10£¬f2= f2*10 where id=10451
ÕâÖÖд·¨»áÔì³Éplsql¿¨ËÀ
²»»á°É£¬ÄǸöid=10451 µÄÊý¾ÝÓжàÉÙ°¡~~~~

ÎÒ¹À¼ÆsqlÊDz» ......

sql×Ö·û´®Ìæ»»(ÓеãÌôÕ½···)

±ÈÈç ÓÐÒ»×Ö¶ÎΪ£º
Num
6111
6201
6520
65121
60087
46300

ÎÒÏë°Ñ6¿ªÍ·µÄÈ«¶¼Ìæ»»³É5¿ªÍ·

×¢ÒâÕâÊDZíÀïµÄÊý¾Ý£¬ÎÒÏëÓÃSQLÓï¾äʵÏÖÌæ»»
SQL code:
update tb set
num = s ......

ÇóÖúÒ»¾äSQLÓï¾ä

Êý¾ÝÀàÐÍ£º
Code char(6)
CreateTime datetime
Price float

Êý¾ÝÈçÏ£º

Code      CreateTime          Price
031021 2008-10-17 15:00:1 ......

Èç¹û´æ´¢¹ý³ÌÊÇÆ´µÄSQL£¬ÄÇôҪ·ÀÖ¹×¢È룬Ôõô°ì£¿

ÊDz»ÊÇÖ»ÄÜÔÚÖ´Ðд洢¹ý³Ì֮ǰÌæ»»µôÃô¸Ð×Ö·ûÁË£¿
Ó¦¸ÃÊǵģ¬¿ÉÒÔÓÃÕýÔòÈ¥Ìæ»»

ÒýÓÃ
Ó¦¸ÃÊǵģ¬¿ÉÒÔÓÃÕýÔòÈ¥Ìæ»»


µÃ´ç½ø³ßµÄÎÊÏ£¬³ýÁËÌæ»»µ¥ÒýºÅ£¬»¹ÐèÒªÌæ»»ÄÄЩÄØ£¿Ð»Ð»~

C# code:

ÎÒ×Ô ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ