Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Invalid Column Name error
Message
De
11/11/2010 09:20:45
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01488773
Message ID:
01488812
Vues:
25
Ah, well I didn't mean to. I just copy and pasted in and it worked. Thanks
Tim

>Why did you change the function from what I posted?
>
>
>CREATE FUNCTION [dbo].[fnSplit]
>(@list  VARCHAR(8000),
> @delim CHAR(1) = ','
>) RETURNS TABLE AS
>RETURN
>   WITH csvtbl(START, stop) AS (
>     SELECT START = 1,
>            stop = CHARINDEX(@delim COLLATE Slovenian_BIN2, @list + @delim)
>     UNION ALL
>     SELECT START = stop + 1,
>            stop = CHARINDEX(@delim COLLATE Slovenian_BIN2,
>                             @list + @delim, stop + 1)
>     FROM   csvtbl
>     WHERE  stop > 0
>  )
>  SELECT row_number() over (order by Start) as ID, LTRIM(RTRIM(SUBSTRING(@list, START,
>                      CASE WHEN stop > 0 THEN stop - START ELSE 0 END)))
>         AS VALUE
>  FROM   csvtbl
>  WHERE  stop > 0
>
>
>Note the UNION ALL part.
>
>>>>Hmm, I like this approach using the function but I am a bit embarassed to say I am not sure what type of function that would be. Where do I put this? There are several categories under functions.
>>>>
>>>
>>>It should be table valued inline function.
>>
>>
>>Naomi, I get this error when I try to create the function
>>
>>Msg 252, Level 16, State 1, Procedure fnSplit, Line 10
>>Recursive common table expression 'csvtbl' does not contain a top-level UNION ALL operator.
>>
>>
>>Here is the function as I typed it from your post
>>
>>SET ANSI_NULLS ON
>>GO
>>SET QUOTED_IDENTIFIER ON
>>GO
>>
>>CREATE FUNCTION [dbo].[fnSplit] 
>>(
>>	@list varchar(8000),
>>	@delim CHAR(1) = ','
>>)
>>RETURNS Table
>>AS
>>	RETURN
>>	WITH csvtbl(START, stop) AS
>>	(
>>		SELECT START = 1,
>>			Stop = CHARINDEX(@delim COLLATE Slovenian_BIN2,
>>							@list + @delim, stop + 1)
>>		FROM csvtbl
>>		WHERE stop > 0
>>	)
>>	SELECT row_number() over (order by START) AS ID, LTRIM(RTRIM(SUBSTRING(@list, START,
>>								CASE WHEN stop > 0 THEN stop - START ELSE 0 END)))
>>			AS VALUE
>>	FROM csvtbl
>>	WHERE stop > 0
>>GO
>>
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform