On dirait que vous besoin de quelque chose le long des lignes de ce:
CREATE FUNCTION [dbo].[Split_String]
(
@ConcatValues VARCHAR(MAX)
)
RETURNS @Values Table
(
Value VARCHAR(MAX)
)
AS
/**************************************************************************************************************
Purpose: When called from a stored procedure and passed a character delimited parameter (of String data type values),
this function returns a table named "@Values" with a field named "Value" (populated with the parameter list)
which can then be referenced in the stored procedure.
This function requires that the delimited paramater have as its first character the delimiter character.
Sample calls:
Select * from [dbo].[Split_String](';dog;cat;mouse')
Select * from [dbo].[Split_String]('| dog| cat| mouse|')
Select * from [dbo].[Split_String]('|')
Select * from [dbo].[Split_String]('')
**************************************************************************************************************/
BEGIN
--Indexes to keep the position of searching
DECLARE @Delim CHAR(1)
Declare @Pos1 Int
Declare @Pos2 Int
--Identify delimiter character
SET @Delim = SUBSTRING(@ConcatValues, 1, 1)
--Append delimiter character
Set @ConcatValues = @ConcatValues + ' ' + @Delim
--Set 1st character of 1st value
Set @Pos2 = 2
While @Pos2 < Len(@ConcatValues)
BEGIN
Set @Pos1 = CharIndex(@Delim, @ConcatValues, @Pos2)
Insert @Values SELECT LTRIM(RTRIM(Substring(@ConcatValues, @Pos2, @Pos1 - @Pos2)))
--Go to next non-delimiter character
Set @Pos2 = @Pos1 + 1
END
RETURN
END
GO
Notre fonction split est générique pour être utilisé dans une grande variété de situations et dépend le délimiteur étant identifié par le premier caractère de la chaîne. Il est probable qu'il pourrait être simplifié un peu si vous en avez seulement besoin en un seul endroit.
Je pense que vous pourriez avoir besoin de plus d'informations ici. Que comptez-vous faire avec ces identifiants? doivent-ils aller dans une clause where? –
Oui nathan, son aller à la clause where.pour mettre à jour les identifiants perticular dans les tableaux. en utilisant ce sP. – user300485