thejamie
2009-06-24 16:30:01 UTC
"Incorrect syntax near '' Expecting ID, QUOTED_ID, '.', or PSEUDOCOL"
Platform SQL 2008
I could find no error reference. There is also nothing regarding a
'PSEUDOCOL' type.
To reproduce:
CREATE FUNCTION [dbo].[fnCSVToTable] ( @StringInput VARCHAR(8000) )
RETURNS @OutputTable TABLE ( [String] VARCHAR(10) )
AS
BEGIN
DECLARE @String VARCHAR(10)
Declare @fldname varchar(10)
Declare @cnt tinyint
Set @cnt=1
WHILE LEN(@StringInput) > 0
BEGIN
SET @String = LEFT(@StringInput,
ISNULL(NULLIF(CHARINDEX(',', @StringInput) -
1, -1),
LEN(@StringInput)))
SET @StringInput = SUBSTRING(@StringInput,
ISNULL(NULLIF(CHARINDEX(',',
@StringInput), 0),
LEN(@StringInput)) + 1,
LEN(@StringInput))
Set @fldname='F'+convert(varchar(3),@cnt)--quotename(@fldname,'''')
INSERT INTO @OutputTable ( @fldname )
VALUES ( @String )
set @cnt=@cnt+1
END
RETURN
END
Still receive an error if the @fldname is replaced by
quotename(@fldname,'''') however, the error makes sense in the latter case.
Platform SQL 2008
I could find no error reference. There is also nothing regarding a
'PSEUDOCOL' type.
To reproduce:
CREATE FUNCTION [dbo].[fnCSVToTable] ( @StringInput VARCHAR(8000) )
RETURNS @OutputTable TABLE ( [String] VARCHAR(10) )
AS
BEGIN
DECLARE @String VARCHAR(10)
Declare @fldname varchar(10)
Declare @cnt tinyint
Set @cnt=1
WHILE LEN(@StringInput) > 0
BEGIN
SET @String = LEFT(@StringInput,
ISNULL(NULLIF(CHARINDEX(',', @StringInput) -
1, -1),
LEN(@StringInput)))
SET @StringInput = SUBSTRING(@StringInput,
ISNULL(NULLIF(CHARINDEX(',',
@StringInput), 0),
LEN(@StringInput)) + 1,
LEN(@StringInput))
Set @fldname='F'+convert(varchar(3),@cnt)--quotename(@fldname,'''')
INSERT INTO @OutputTable ( @fldname )
VALUES ( @String )
set @cnt=@cnt+1
END
RETURN
END
Still receive an error if the @fldname is replaced by
quotename(@fldname,'''') however, the error makes sense in the latter case.
--
Regards,
Jamie
Regards,
Jamie