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

SQLÖÐ ³£ÓõĴ¦Àí·½·¨

 -- Ò»£º ´¦Àíδ²éµ½µÄ¿ÕÖµ
 select
 case when exists(select EndPrice from T_stock where BOMSN='0109')
 then (select EndPrice from T_stock where BOMSN='0109')
 else 0 end
 --¶þ£º¸üÐÂ×Ö¶ÎÖµ
 --strNum ÊýÁ¿
 --strId  ÐòºÅ
 update T_buy_Pro set CompentNum=isnull(CompentNum,0)+'strNum' ,
 Status= case when isnull(BuyNumber,0) > isnull(CompentNum,0)+ 'strNum'
 then '²¿·ÖÊÕÁÏ' else 'È«²¿ÊÕÁÏ' end
 where BuyProID='strId'
È¥µôСÊýµãÓÐЧÊý×ÖºóÃæµÄËùÓÐ0
decimalÀàÐÍ£¬Ð¡ÊýλÊýÊÇ6룬Èç¹û²åÈëµÄÊý¾ÝΪ2.5£¬Ôò¼ìË÷ʱÏÔʾΪ2.500000
select   cast(2.500000       as     real)
----------½¨Ò»個º¯數Íê³É-------------   
  Create     Function     trun(@i     decimal(18,6))   
  returns       varchar(30)   
  begin     
  declare     @s     varchar(30)   
  set     @s=cast(@i     as   varchar(30))   
  while   len(@s)>0   
  begin           
            if   cast(substring(rtrim(@s),len(rtrim(@s))-1,1)     as     int)<>0         
            begin   
                    set     @s=substring(rtrim(@s),1,len(@s)-1)   
                    break   
            end   
            set     @s=substring(rtrim(@s),1,len(@s)-1)   
  end   
        return(@s)   
  end   
  ----------------------------結Êøº¯數--------


Ïà¹ØÎĵµ£º

SQL Server´æ´¢¹ý³Ì

Ê×ÏȽéÉÜÒ»ÏÂʲôÊÇ´æ´¢¹ý³Ì£º´æ´¢¹ý³Ì¾ÍÊǽ«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´£¬²¢ÇÒÕâÑùµÄÓï¾äÊÇ·ÅÔÚÊý¾Ý¿âÖеģ¬»¹¿ÉÒÔ¸ù¾ÝÌõ¼þÖ´Ðв»Í¬SQLÓï¾ä£¬ ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ£¬Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî¡£
¡¡¡¡Çë´ó¼ÒÀ´Á˽âһϴ洢¹ý³Ìµ ......

SQL Server 2005 ²éѯ·ÖÎöÖÐɾ³ýÊý¾Ý¿â

USE   master  
GO
DECLARE   @dbname   sysname  
SET  @dbname='TEST' --Õâ¸öÊÇҪɾ³ýµÄÊý¾Ý¿â¿âÃû  
DECLARE @s  NVARCHAR(1000)  
DECLARE tb CURSOR local FOR  
SELECT s='KILL '+CAST(spid AS NVARCHAR)&nbs ......

SQL ½«ÁÐת»»ÎªÐУ¬Ï൱ÓÚ½«±í½á¹¹Ðýת90¶È

½«ÁÐת»»ÎªÐУ¬Ï൱ÓÚ½«±í½á¹¹Ðýת90¶È
T_Student ±í
Stud_ID
Sex
Name
1
ÄÐ
Tom
2
Å®
Anne
3
ÄÐ
Jack
 
Ö´ÐÐ: Exec proColumnToRow ’T_Student’,’Name’,’ New_ID’
 
ת»»ºóµÄ±í
 
New_ID
Tom
Anne
Jack
Stud_ID
1
2
3
Sex
ÄÐ
Å®
ÄÐ
& ......

SQL ѧϰ±Ê¼Ç Like²Ù×÷·û

LIKE ²Ù×÷·ûÓÃÓÚÔÚ WHERE ×Ó¾äÖÐËÑË÷ÁÐÖеÄÖ¸¶¨Ä£Ê½¡£
SQL LIKE ²Ù×÷·ûÓï·¨
SELECT column_name(s) from table_name WHERE column_name LIKE pattern
SQL ͨÅä·û
ÔÚËÑË÷Êý¾Ý¿âÖеÄÊý¾Ýʱ£¬SQL ͨÅä·û¿ÉÒÔÌæ´úÒ»¸ö»ò¶à¸ö×Ö·û¡£
SQL ͨÅä·û±ØÐëÓë LIKE ÔËËã·ûÒ»ÆðʹÓá£
ÔÚ SQL ÖУ¬¿ÉʹÓÃÒÔÏÂͨÅä·û£º
ͨÅä·û
Ãè ......

SQL HexString Óë Binary »¥»»

HexString to Binary:
DECLARE @y CHAR(34)
SET @y = '0x499104dc92dd27499da9ad8f56dcb437'
DECLARE @x BINARY(16)
DECLARE @sql NVARCHAR(200)
SET @sql = 'SELECT @x = ' + @y
EXEC sp_executesql
@sql,
N'@x BINARY(16) OUTPUT',
@x OUTPUT
SELECT @x
Binary to HexString:
DECLARE @a VARBINARY(20)
SET ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ