Monday, December 7, 2015

Get column name and column name count

declare @colindex int
declare @colcount int
declare @tableid int
declare @colname varchar(100)

set @tableid = ( select id from sysobjects where name='tblUsrShrProp' )
set @colcount = ( select COUNT(*) from syscolumns where id = @tableid )

set @colindex = 1
while @colindex <= @colcount
begin
  set @colname = ( select name from syscolumns where id = @tableid and colorder = @colindex )
  print @colname
  set @colindex = @colindex + 1
end


select @colcount as columncountname

No comments:

Post a Comment

Find the value from array when age is more than 30

 const data = [   { id: 1, name: 'Alice', age: 25 },   { id: 2, name: 'Bob', age: 30 },   { id: 3, name: 'Charlie', ...