Msg 102, Level 15, State 1, Procedure <process_name>, line 40 Incorrect syntax near '('

 select * from dbo.split(RTRIM(@importRow), '¬') 

gives an error:

Msg 102, Level 15, State 1, proc_name Procedure, Line 40
Invalid syntax near '('.

What is the correct syntax for this line? Some time has passed since I correctly executed SQL and was unable to execute this part of the script for my whole life!

Using SQL Server 2005

Sorry for the name. Not quite sure what to put otherwise than "Syntax error"!

Edit: Code for SPLIT:

 CREATE FUNCTION [dbo].[Split] ( @String VARCHAR(4000), @Delimiter VARCHAR(5) ) RETURNS @SplittedValues TABLE ( OccurenceId SMALLINT IDENTITY(1,1), SplitValue VARCHAR(4000) ) AS BEGIN DECLARE @SplitLength INT WHILE LEN(@String) > 0 BEGIN SELECT @SplitLength = (CASE CHARINDEX(@Delimiter,@String) WHEN 0 THEN LEN(@String) ELSE CHARINDEX(@Delimiter,@String) -1 END) INSERT INTO @SplittedValues SELECT SUBSTRING(@String,1,@SplitLength) SELECT @String = (CASE (LEN(@String) - @SplitLength) WHEN 0 THEN '' ELSE RIGHT(@String, LEN(@String) - @SplitLength - 1) END) END RETURN END GO 

And the code to start the procedure

 CREATE PROCEDURE dbo.[procedure] -- Add the parameters for the stored procedure here @RETURN_VALUE int, @importRow VarChar(8000) ...... 
+4
source share
1 answer

Move RTRIM to UDF itself (based on comments)

This is good practice, so RTRIM is not needed for every use of split UDF.

+3
source

Source: https://habr.com/ru/post/1381489/


All Articles