ethar turky
asked on
Serial Number with COALESCE function
Dear all,
I use The following :
I need to generate :
thanks,
I use The following :
DECLARE @Names VARCHAR(8000) ;DECLARE @i int=0;
SELECT top 10 @Names = COALESCE(@Names +', ', '') + '[' + COLUMN_NAME+ ']'
FROM dbo.site_DatabaseFields
where TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME = 'JDB.dbo.Invoices'
SELECT @Names
To Generate : [AccNo], [Attach], [BankName], [Branch], [BranchSer], [CName], [City], [CriditPeriod], [CusPO], [DiffDay]
I need to generate :
[AccNo] as Field1, [Attach] as Field2, [BankName] as Field3, [Branch] as Field4, [BranchSer] as Field5, [CName] as Field6, [City] as Field7, [CriditPeriod] as Field8, [CusPO] as Field9, [DiffDay] as Field10
thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
e.g.
SELECT top 10 @Names = COALESCE(@Names +', ', '') + QUOTENAME(COLUMN_NAME)