Activity overview
Latest activity by PaulShearing
I too have this problem. The TSQL TRIM function can take an additional parameter which is the string sequence (usually a single character) to be removed from the start and end of a string. The default value is the single space character, as in: TRIM(@stringVar) which works fine but TRIM(',', @stringVar) to remove leading or trailing commas causes SqlPrompt to display an error panel. My little string tidy function is: <div><i>create function [Maintenance].[strTidy]</i></div><div><i>(</i></div><div><i> @str NVARCHAR(max)</i></div><div><i>)</i></div><div><i>returns NVARCHAR(max)</i></div><div><i>as</i></div><div><i> begin</i></div><div><i> declare @ResultVar NVARCHAR(max);</i></div><div><br></div><div><i> set @ResultVar = TRIM( COALESCE( @str, '' ));</i></div><div><i> set @ResultVar = TRIM( ',' from @ResultVar); <b><<-- Comment this line and SQL Prompt is OK</b></i></div><div><i> set @ResultVar = REPLACE( @ResultVar, ' ', ' ' );</i></div><div><i> if @ResultVar = 'undisclosed'</i></div><div><i> set @ResultVar = N'';</i></div><div><br></div><div><i> return @ResultVar;</i></div><div><br></div><div><i> end</i></div> SQL Prompt VS 9.5.16.11294 SQL Server: 14.0.2027.2 / comments
I too have this problem. The TSQL TRIM function can take an additional parameter which is the string sequence (usually a single character) to be removed from the start and end of a string. The defa...