Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Á½Áкϲ¢ÏÔʾ£¿

²éѯ½á¹û¼¯£º
ps  online  totle
a    0      10
b    1      11
c    5        8
ÏëÏÔʾ³ÉÕâÑù ......

Çó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 ´æ´¢¹ý³Ì ¶¯Ì¬±í DateTimeÊý¾ÝÀàÐÍ Ìí¼ÓÎÊÌâ

ÎÒµÄÊý¾Ý¿âµÄ±íÊǶ¯Ì¬µÄ±í,ÔÚÌí¼ÓÊý¾ÝµÄʱºòÓÐÒ»¸ö×Ö¶ÎÊÇDATETIMEÊý¾ÝÀàÐ͵Ä,ÏÂÃæÊÇ´æ´¢¹ý³Ì
if exists (select * from sysobjects where name='proc_ADD_Order')
drop proc proc_ADD_Order
go
......

ÇóÒ»sqlÓï¾ä¡£

±íÖÐÊÇÕâÑù£¬
²¿ÃźŠ   ²¿ÃÅÐÅÏ¢
  1        ²¿ÃÅÒ»
  2        ²¿ÃŶþ
  3        ²¿ÃÅÈý
  4& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ