sp语句二

*************************************************************************/
ALTER PROC [dbo].[P_DeleteNewSupplierByIDAtInV2]
(    
    @supplierId            int,
    @databasename    NVARCHAR(200)
)
AS
BEGIN
DECLARE @sqlA NVARCHAR(200)
DECLARE @sqlB NVARCHAR(200)
SET @sqlA = @databasename + '.dbo.aspnet_Users'
SET @sqlB = @databasename + '.dbo.aspnet_Membership'
DECLARE @sql    NVARCHAR(500)
DECLARE @userID NVARCHAR(200)
declare @MemeberId NVARCHAR(500)
set @MemeberId='select MemberID from dbo.T_IMeetSupplierMember sp where sp.IMeetSupplierID=''+ @supplierId + '''

SET @userID = 'SELECT Userid FROM '+ @sqlB+ ' WHERE  MemberID in '''+ @MemeberId + ''''

SET    @sql =' DELETE FROM '+ @sqlB +' WHERE MemberID in '+@MemeberId+''+ 'DELETE FROM '+ @sqlA +' WHERE UserId in '''+ @userID+''''

PRINT(@sql)
EXEC(@sql)        
    IF @@ERROR = 0
    BEGIN    
      SELECT 1
    END
    ELSE
    BEGIN      
      SELECT 0
    END
END

--P_DeleteNewSupplierByIDAtInV2 112025, 'IMeetDB_V2'
posted on 2009-08-06 17:19  prayforsmile  阅读(250)  评论(0编辑  收藏  举报