Use this function to throw double-quotes around text fields if they contain a comma:
ALTER function fn_QuoteCSV
(
@input varchar(4000)
)
RETURNS varchar(4000)
AS
BEGIN
declare @rtn varchar(4000)
select @rtn=@input
IF CHARINDEX(',',@input) > 0
BEGIN
select @rtn = QUOTENAME(@input,CHAR(34))
END
return @rtn
END
No comments:
Post a Comment