in 的问题
写了个自定义函数,把一个表的主键   连接成一个字符串!   
 然后利用   select   *   from   songs   where   cast(s_id   as   varchar)   in   (dbo.GetSongsIDS(56))   
 dbo.GetSongsIDS(56)   得到了一个串,比如:156,165,145,158   
 但是上面的   select      语句却查不到数据~~   
 为什么呢?     
 而   select   *   from   songs   where   cast(s_id   as   varchar)   in   (156,165,145,158)   
 有数据!什么原因呢?     
------解决方案--------------------select * from songs where cast(s_id as varchar) in (156,165,145,158)   
 不等于   
 select * from songs where cast(s_id as varchar) in ( '156,165,145,158 ')     
 你可以这样写: 
 select * from songs where charindex( ', '+cast(s_id as varchar)+ ', ' ,  ', ' + dbo.GetSongsIDS(56) + ', ')
------解决方案--------------------LS解释正确,你的函数得到的是一个字符串,in这个字符串相当于就是和这个字符串的整体比较,不会再按照你理解的分隔匹配了。   
 可以采用LS的方式在SQL里拆分这个字符串比较
------解决方案--------------------呵呵,不能算拆分。说是构造比较吧   
 select * from songs where charindex( ', '+cast(s_id as varchar)+ ', ' ,  ', ' + dbo.GetSongsIDS(56) + ', ')> 0
------解决方案--------------------因为你得到的是一个字符串,而不是一组
------解决方案--------------------用charindex()   
 select * from songs where charindex( ', '+cast(s_id as varchar)+ ', ' ,  ', ' + dbo.GetSongsIDS(56) + ', ')> 0