SQLȡֵÎÊÌâ - MS-SQL Server / »ù´¡Àà
±ítable
A B
12*2+10*5
4*3+10*4
15*2+81*4
ÈçºÎÈ¡BÁÐÖеÚÒ»¸ö*ºÅǰµÄÊý£¬²¢¸³¸øAÁÐ
--search
SQL code:
select left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1)
--update
SQL code:
update table
set a = left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1)
select left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1) > 0
update table set a = left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1) > 0
SQL code:
update ±ítable set A=left(B,charindex('*',B)-1)
¶¼ÊÇÅ£È˰¡¡£
û¶àÉÙ·Ö£¬ºÇºÇ£¬È¨µ±Òâ˼Ï¡£ÐÂÊÖ¡£¡£²»ºÃÒâ˼¡£
Ïà¹ØÎÊ´ð£º
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ãæ£¬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......
½«Ò»¸ö²éѯÓï¾ä¸³¸øÒ»¸ö±äÁ¿£¬ÈçÏ£º
DECLARE @STR NVARCHAR(MAX)
SET @STR='SELECT * from SALE_PROD'
ÔõôÑù²ÅÄÜÖ´ÐÐËüÄØ£¿
Çë¸ßÊÖ£¬ÈÊÐÖ£¬ÏÀ½ã°ï°ïæ°¡
¶àл£¬¿ÉÒÔÀ²£¬¸ßÊÖ°¡
Ö±½ÓÖ´ÐоÍÐÐÁË
exec ......
±íÊý¾Ý
COL1 COL2 COL2 COL4 COL5
----------------------------------------------------------------------------------------------
2010-05-05 00:00 ......