First create a function to split your string into separate values:
CREATE FUNCTION dbo.splitstring ( @separador CHAR, @stringToSplit VARCHAR(MAX) )
RETURNS
@returnList TABLE ([Name] [nvarchar] (500))
AS
BEGIN
DECLARE @name NVARCHAR(255)
DECLARE @pos INT
WHILE CHARINDEX(@separador, @stringToSplit) > 0
BEGIN
SELECT @pos = CHARINDEX(@separador, @stringToSplit)
SELECT @name = SUBSTRING(@stringToSplit, 1, @pos-1)
INSERT INTO @returnList
SELECT @name
SELECT @stringToSplit = SUBSTRING(@stringToSplit, @pos+1, LEN(@stringToSplit)-@pos)
END
INSERT INTO @returnList
SELECT @stringToSplit
RETURN
END
Call the created function by passing a string containing the values separated by "!":
SELECT * FROM dbo.splitstring('!', '91!12!65!78!56!789')
The result for this query will be below:
To insert the values in your other table, simply adapt the following command according to the columns you have in your table:
INSERT INTO TabelaDeDestino SELECT Name FROM dbo.splitstring('!', '91!12!65!78!56!789')
This is an adaptation of the answer in English https://stackoverflow.com/questions/10914576/t-sql-split-string
If you are interested in knowing other approaches to separate the numbers, I suggest reading the article "Separating multi-valued text content (split string)". Access https://portosql.wordpress.com/2019/01/27/separar-textualcontent_multivalorado_string-split/
– José Diz