• hi Jack,

    thanks for your articel.

    but I still have a question (hopefully it is ok to post questions/problems here, if not: sorry folks, i'm quite new here):

    I get a csv string from the UI that has to be devides in several columns.

    this procedure has to run very fast, so i splitted the necessary actions (because otherwise it is to slow and some information is lost):

    1. procedure which inserts the whole csv string in one column. (this proc has to check if one csv string contains only one or more rows and then inserts it into the table.)

    like '1211224,45345,35636,3453453,3453456,...)

    2. job, which copies the new data as it is to another sql-server every 5 minutes (necessary because UI is located on a DMZ and the information has to be stored in the internal sql server)

    now the trigger problem:

    if the new data is inserted, i run a trigger, which splits the information in the different columns. I do not see any possibility to make an update for all the rows in the inserted as you mentioned, because the split works with a function which returns the value before the next coma of the csv-string.

    create trigger trtest

    ...

    declare @Hoehe int, @kmStand int, @text varchar(200)

    select @text = text from inserted

    -- @text is the csv string, @hoehe, @kmstand .. are variables which are used in the update statement

    set @text = dbo.fKomma(@text)

    set @Hoehe = dbo.fWert(@text)

    set @text = dbo.fKomma(@text)

    set @kmStand = dbo.fWert(@text)

    ....

    update table set

    hoehe = @hoehe,

    kmstand = @kmstand,....

    where id = @id

    go

    as the trigger is fired only once, i implemented a procedure

    which contains a cursor to make the insert and therefore the trigger is fired for each row.

    create proc pTransfer

    as

    set nocount on

    declare tcursor cursor for

    select daten

    from tblOrtungExt

    order by idortung

    declare @daten varchar(500)

    open tcursor

    fetch next from tcursor

    into @daten

    while @@FETCH_STATUS = 0

    begin

    -- insert in tabel with trigger

    exec pInsertOrtung @daten

    fetch next from tcursor

    into @daten

    end

    close tcursor

    deallocate tcursor

    go

    very long problem...sorry for that. so if you have any time left :), i would be glad about any suggestions.

    Susanne