Sql Function Return varcharCREATE FUNCTION SchemaName.GetValuesCommaSeparated( @Id int)RETURNS varchar(100) -- or whatever length you needASBEGIN declare @values as varchar(100)declare @result as varchar(100) ='' DECLARE cursorValues CURSOR FOR select T.ColumnName from SchemaName.TableName T where T.ID = @Id --OPEN CURSOR. OPEN cursorValues --FETCH THE RECORD INTO THE VARIABLES. FETCH NEXT FROM cursorValues INTO @values
Leggi tutto il post...