need help -Stored Procedure -Incorrect syntax

  • how can i do this

    -------------------------------

    set @na =SELECT [na] FROM [xsisi]

    -----------------------------------

    ---------------

    declare @na varchar(500), @sisi int, @mmh char(10)

    set @sisi='2'

    set @mmh='uuu'

    set @na =SELECT [na] FROM [xsisi]

    UPDATE Sn

    SET [sisi] = @sisi,

    [mmh] = @mmh

    WHERE charindex(','+CONVERT(varchar,[na])+',',','+@na+',') > 0

    --------------------

    thnks ilan

  • Just do:-

    select @na = [na] FROM [xsisi]

  • no it only update one record not all !!!

    i the table [xsisi] i have 100 records

    and like this it update only one

    not the all 100 "FROM [xsisi]"

    -------------

    declare @na varchar(500), @sisi int, @mmh char(10)

    set @sisi='1'

    set @mmh='uuu'

    select @na = [na] FROM [xsisi]

    UPDATE Sn

    SET [sisi] = @sisi,

    [mmh] = @mmh

    WHERE charindex(','+CONVERT(varchar,[na])+',',','+@na+',') > 0

    -----------------------

  • select @na = @na + cast([na] as varchar) + ',' FROM [xsisi] 

    Would'nt it be better to rewrite the query thus

    UPDATE a
    
    SET a.sisi = @sisi,a.mmh = @mmh
    FROM Sn a
    INNER JOIN [xsisi] b ON b.na = a.na

    Far away is close at hand in the images of elsewhere.
    Anon.

  • OK i workig 100%

    thnks

    a little question

    how can i add more filed to update

    like

    ----------------

    @Fname[nvarchar](50),@fld1 [smalldatetime], @fld2[int],

    -----------------------

    i wont to learn the method

    ---------------------------

    declare @na varchar(500), @sisi int, @mmh char(10)

    set @sisi='2'

    set @mmh='uuu'

    select @na = @na + cast([na] as varchar) + ',' FROM [vsisi]

    UPDATE a SET a.sisi = @sisi,a.mmh = @mmh

    FROM Sn a INNER JOIN [vsisi] b ON b.na = a.na

    --------------

    thnks a lot

    ilan

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply