declare @num int,@tableName varchar(50),@columnName varchar(50),
@typeName varchar(50),@max_length int,@str varchar(500) = ''
declare cur_table cursor for
with cte(num,tableName,columnName,typeName,max_length) as (
select row_number() over(order by ia.name asc) 'Num' ,
ia.name 'tableName',ib.name 'columnName',
ic.name 'typeName',ib.max_length
from test.sys.objects ia
inner join test.sys.columns ib
on ia.object_id = ib.object_id
inner join test.sys.types ic
on ib.user_type_id = ic.user_type_id
where ia.type ='U' and ia.name = 'abc'
) select num,tableName,columnName,typeName,max_length from cte;
open cur_table
fetch next from cur_table into @num,@tableName,
@columnName,@typeName,@max_length
while(@@FETCH_STATUS = 0)
begin
if(@typ