i have some what a definition table of the fields of the other tablename as DefinitionTable with data as followsFieldType FieldName1 FieldDesc TxtColor FontStyle8 FIELD1 ABC #1111 [fsbold] 8 FIELD2 CDE #2222 [fsitalic] 8 FIELD3 EFG #3333 [fsbold]
OrigTableOrigKey FieldType FIELD1 FIEDL2 FIELD3 Results1 8 test1 test2 test3 ok
so the e.g. FIELD1 is a data in DefinitionTable and a field name in OrigTable..my problem is how to get the TxtColor in merging this table.. my sp in fetching the data but only the fielddescription iscreate procedure Definition@SearchKey int,@FieldTypeintasbegin DECLARE @FieldName varchar(10), @FieldDesc varchar(30), @TextColor int, @mysql varchar(4000) SET NOCOUNT ON SELECT @mysql = 'select o.origkey, ' DECLARE MyCursor CURSOR READ_ONLY FOR SELECT FieldName1, FieldDesc FROM DefinitionTable WHERE FieldType = @ResultType Open MyCursor FETCH NEXT FROM MyCursor INTO @FieldName, @FieldDesc WHILE @@FETCH_STATUS = 0 BEGIN select @mysql = @mysql + 'o.' + @FieldName + ' as ' + @FieldDesc + ', ' FETCH NEXT FROM MyCursor INTO @FieldName, @FieldDesc END CLOSE MyCursor DEALLOCATE MyCursor select @mysql = @mysql + ' o.results from OrigTable o where FieldType = ' + @ResultType execute(@mysql) end
the result is Ok asOrigKey ABC CDE EFG Result8 test1 test2 test3 ok
But the problem is how to include the TxtColor or concatenate TxtColor with this output belowOrigKey ABC CDE EFG Result8 test1+##1111 test2+#222 test3+#3333 ok
thanx,mygt