wudi

博客园 首页 新随笔 联系 订阅 管理

//登陆

ALTER PROCEDURE [dbo].[Proc_CheckUser]
 @CheckName varchar (50) ,
 @Result varchar(20) OUtPUT
AS
BEGIN

 SET NOCOUNT ON;
declare @WhereStr varchar (500), @SQLStr   Nvarchar(4000),@re   bit

IF(left(@CheckName,5)='95002' and isnumeric(@CheckName)=1) SET @CheckName=substring(@CheckName,6,len(@CheckName))--  登陆号码前+95002

IF(isnumeric(@CheckName)=1) SET @WhereStr='UID = '''+@CheckName+''''--  登陆号码前+95002
IF((left(@CheckName,2)='13' OR left(@CheckName,2)='15' and len(@CheckName)=11) and isnumeric(@CheckName)=1) SET @WhereStr='Phone = '''+@CheckName+''''--  手机号码
IF(left(@CheckName,1)='0'  and isnumeric(@CheckName)=1 and (len(@CheckName) between 10 and 13)) SET @WhereStr='TelePhone = '''+@CheckName+''''  --  固定电话
IF(Charindex('@',@CheckName)>0 and Charindex('.',@CheckName)>0 and isnumeric(@CheckName)=0) SET @WhereStr='Email = '''+@CheckName+''''  --  email

  SET   @SQLStr   =   'set   @re=case   when   exists(select 0 from Passport_Account where '+@WhereStr+' and 1=1)   then   1   else   0  end'
  exec   sp_executesql   @SQLStr,N'@re bit output,@WhereStr varchar(500)',@re output,@WhereStr
if   @re=1
 BEGIN
 SET @SQLStr=N'select @Result=UID from Passport_Account where '+@WhereStr+'  and 1=1'
 exec   sp_executesql  @SQLStr ,N'@Result varchar(20) output,@WhereStr varchar(500)',@Result output,@WhereStr
 SET @Result='1'+@Result
 Print @Result
 END
ELSE
 BEGIN
 SET @Result=0
 print 0
 END

END

 

 

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

 

 

//分割字符串

-- =============================================
-- Author:  <Author,,wudi>
-- Create date: <Create Date,2008-7-30,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[Proc_UpdateSongID]
 -- Add the parameters for the stored procedure here
@SongID varchar(50)
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;
-- declare @strSql varchar(100)
-- SET @strSql = 'update table_dgsong set state=1 where songid in('+@SongID+')';
-- EXEC (@strSql);
 create table #tmp(SongID int);
 declare @len int
 set @len=len(@SongID);

 --print @len
 while @len<>0
BEGIN
  declare @sid VARCHAR(20)
  set @sid=left(@SongID,1);
  if(@sid<>',')
   begin
    insert into #tmp values (@sid)
    set @SongID=right(@SongID,len(@SongID)-1);
   end
  else
   begin
    set @SongID=right(@SongID,len(@SongID)-1);
   end
  SET @LEN=@LEN-1
  
END
 update table_dgsong set state=1 where songid in(SELECT SongID FROM #tmp)


END

 

 

posted on 2008-04-25 17:02  菜鸟吴迪  阅读(349)  评论(0编辑  收藏  举报