declare @colNum int, @i int = 1, @a nvarchar(4000)
select @colNum=count(COLUMN_NAME) from INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'YourTable'
set @a = '
declare @tempTable table
(
slno int
,field nvarchar(100)
,value nvarchar(100)
)
insert into @tempTable (slno,field)
select ROW_NUMBER() over (order by ordinal_position asc),COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = ''YourTable''
declare @p nvarchar(100)
'
declare @colname nvarchar(100)
while @i<[email protected]
begin
select @colname =a.COLUMN_NAME from (select COLUMN_NAME,ORDINAL_POSITION
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'YourTable'
)as a
where a.ORDINAL_POSITION = @i
set @a = @a + '
select @p='[email protected]+' from YourTable
update @tempTable set
value = @p
where slno = '+CONVERT(nvarchar(5), @i)
+'
'
set @[email protected]+1
end
set @a = @a + ' select * from @tempTable'
declare @tempTable table
(
slno int
,field nvarchar(100)
,value nvarchar(100)
)
insert into @tempTable exec (@a)
select * from YourTable
select * from @tempTable
필요
??? –
보고서에 표시하려면 –
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:419593546543 및 https://forums.oracle.com/thread/1113915 이러한 링크가 도움이 될 수 있습니다 ... –