dd_FL

This is a piece of code that will generate a field list for a table. I know there are lots of other ways to do this... but this generates the list exactly the way that I want it (for writing inserts, selects...). For one query I won't bother, but for two or three it's quicker for me. 
IF EXISTS (SELECT name
    FROM   sysobjects
    WHERE  name = N'dd_FL'
    AND    type = 'P')
    DROP PROCEDURE dd_FL
GO
CREATE PROCEDURE dd_FL
-- dd_FL 'POP00101'
@Tablename varchar(50)
AS
 
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @FieldList as varchar(max)
 
select @FieldList = coalesce(@FieldList + ',','') + rtrim(c.COLUMN_NAME)
    FROM INFORMATION_SCHEMA.COLUMNS c
    WHERE c.TABLE_NAME = @Tablename
    ORDER BY c.ORDINAL_POSITION
 
SELECT @FieldList
GO
grant exec on dd_FL to public

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences