3月 11, 2009

sp charindex


declare @tCount as int
 --declare @學號 nvarchar(50)
 --SET @學號 = '55,5'

 
 SELECT  @tCount = Count(*)
 from
 (
  SELECT [學號] FROM [床位申請明細_個人]
  UNION ALL
  SELECT [學號] FROM [床位申請明細_團體]
 ) AS TMP_TABLE
    --where  [學號]=@學號
 where CHARINDEX([學號],@學號) > 0
 --開必殺技=無敵
 select @tCount AS tCount
 
 return @tCount;


沒有留言: