Friday, June 1, 2012

MultiParameter Table-Valued Functions

Default Script to set the multi-dimentional view in SSRS


USE [Work]  --DB Name
GO
CREATE FUNCTION [dbo].[MultiParameter] 

   @DelimittedString [varchar](max), 
   @Delimiter [varchar](1) 

RETURNS @Table Table (Value [varchar](100)) 
BEGIN 
   DECLARE @sTemp [varchar](max) 
   SET @sTemp = ISNULL(@DelimittedString,'') 
                + @Delimiter 
   WHILE LEN(@sTemp) > 0 
   BEGIN 
      INSERT INTO @Table 
      SELECT SubString(@sTemp,1,
             CharIndex(@Delimiter,@sTemp)-1) 
      
      SET @sTemp = RIGHT(@sTemp,
        LEN(@sTemp)-CharIndex(@Delimiter,@sTemp)) 
   END 
   RETURN 
END 
GO

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.