i want to select from a Table called RMA
(simplified):
idRMA| RMA_Number
-----------------------
1 RMA0006701
2 RMA0006730
3
Here is something that should get you going:
ALTER FUNCTION [dbo].[GetUCColumns]
(@tableid INT, @index INT)
RETURNS VARCHAR (MAX)
AS
BEGIN
DECLARE @cols varchar(max)
SELECT @cols = COALESCE(@cols + ', ', '') + [name]
FROM [sys].[columns]
where object_id = @tableid AND column_id IN
(SELECT [column_id]
FROM [sys].[index_columns]
where object_id = @tableid AND @index = index_id)
RETURN @cols
END