I'm trying to create a little utility that will create all the update sets for a table. It works great except all of the set statements are on the same line. I want to put them each on a separate line. Here is the code.
Can I put characters into a select or return that will provided the formatting that I want???
DECLARE @tableName varchar(100)
set @tablename = 'mytable'
declare @ID int
select @id = id from sysobjects where name = @tablename and xtype = 'u'
if @id is null
BEGIN
raiserror ('Table not found ',16,1)
return
END
BEGIN
declare @list varchar (max)
select @list=isnull(@list + Name + ' = @' + Name + ', ' + char(13) + char(10) ,'')
from syscolumns
where id = @id
select @list as theList
end
Can I put characters into a select or return that will provided the formatting that I want???
DECLARE @tableName varchar(100)
set @tablename = 'mytable'
declare @ID int
select @id = id from sysobjects where name = @tablename and xtype = 'u'
if @id is null
BEGIN
raiserror ('Table not found ',16,1)
return
END
BEGIN
declare @list varchar (max)
select @list=isnull(@list + Name + ' = @' + Name + ', ' + char(13) + char(10) ,'')
from syscolumns
where id = @id
select @list as theList
end