SQL String Concatenation

  • Agree on the first comment, but not on the second. Try this:

    Declare @Var as varchar(1000)

    set @Var = ''

    Select @Var = @Var + case when len(@Var) + len(name + ', ') < 1000 then name + ', ' else '' end

    from dbo.SysObjects order by name

    Select @Var, len(@Var)

Viewing post 16 (of 15 total)

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