Page 1 of 1

TVF_SubscriptionFileName

Posted: Fri Mar 03, 2017 12:00 am
by robinwilson16
Used for generating file paths for SSRS report subscriptions removing all the characters that are not allowed in file paths

Code: Select all

CREATE FUNCTION [dbo].[TVF_SubscriptionFileName]
(
	@String NVARCHAR(MAX)
)
RETURNS TABLE
AS
RETURN 
	--DECLARE @String NVARCHAR(MAX) = 'First & Second/3rd'

	SELECT
		Value = 
			REPLACE ( 
				REPLACE ( 
					REPLACE ( 
						REPLACE ( 
							REPLACE ( 
								REPLACE ( 
									REPLACE ( 
										REPLACE ( 
											REPLACE ( 
												REPLACE ( 
													REPLACE ( 
														REPLACE ( 
															REPLACE ( 
																REPLACE ( 
																	@String, 
																'&', '' ),
															'"', '' ),
														']', '' ),
													'[', '' ),
												',', '' ),
											'+', '' ),
										'|', '' ),
									'>', '' ),
								'<', '' ),
							':', '' ),
						'*', '' ),
					'?', '' ),
				'\', '' ),
			'/', '' )