ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] SqlServerCentral¨C¤é¤@ÃD¤¤¤å¾ã²z

[¤À¨É] SqlServerCentral¨C¤é¤@ÃD¤¤¤å¾ã²z

¥»©«³Ì«á¥Ñ kimbal ©ó 2010-8-30 23:57 ½s¿è

T-SQL ½g

2010-08-04 null »P coalesce
isnull, coalese ªº¤p¤À§O
  1. DECLARE @STR VARCHAR(3)
  2. SET @STR=NULL
  3. SELECT ISNULL(@STR,'GIVEN STRING IS NULL')
  4. SELECT COALESCE(@STR,'GIVEN STRING IS NULL')
½Æ»s¥N½X
select¥X¨Ó«áµ²ªG¬O 'GIV' ©M 'GIVEN STRING IS NULL'
ISNULL·|¥ý¬d¬Ý@STRÃþ«¬. ¦ýCOALESE ´N¤£·|


2010-08-30 '' »P 0
  1. create table  #temp(id INT, code nvarchar(2))
  2. insert into #tempselect 1, '0' UNION
  3. select 2, '1' UNION
  4. select 3, '0' UNION
  5. select 4,'22' UNION
  6. select 5,'0'
  7. update #temp set code = '' where code = '0'
  8. select * from #temp where code = 0
  9. drop table #temp
½Æ»s¥N½X
³Ì«á¦^¶Ç3¦æ
'' = 0
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

nullªº¥Îªk¤F¸Ñ,¦ýcoalesce¨S¬Ý¹L,«Ü¤[¨S¯AÂy,¸ò¤£¤W¤j¤jªº¸}¨B,ê©ó¸ò¦ÑªF®a¦³«O±K±ø´Ú,¤£µM´N¥i¥H¥Î¥H«eªºµ{¦¡¨Ó¸ò¤j¤j±´°Q,¬ã¨s·sªº¼¶¼g¤è¦¡

TOP

        ÀR«ä¦Û¦b : ¬O«D·í±Ð¨|¡AÆg¬ü§@ĵ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD