June 30, 2005 at 1:41 am
Is there any inbuilt procedure to find total number of ciolumns in a table.
I searcehd some system stored procedure but not able to locate.
Can any one guide me on this.
Pavas
Dream The Dream
Explore the World
Experince The Exhilaration
June 30, 2005 at 1:56 am
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'foobar'
June 30, 2005 at 10:54 pm
Thanks a lot this works fine
Pavas
Dream The Dream
Explore the World
Experince The Exhilaration
June 30, 2005 at 11:53 pm
Can we find total number of columns of a #Table in side a stored procedure
Pavas
Dream The Dream
Explore the World
Experince The Exhilaration
July 1, 2005 at 12:14 am
Hmm, I can't think of a way to do this. Why do you need this?
July 1, 2005 at 10:16 am
Hi
You can do like this
select count(*) from tempdb..syscolumns where id = object_id(<temporary table name>
Thanks
July 4, 2005 at 1:40 am
Hi amish i tried doing the below statements i am not able to get the results
CREATE tABLE #T
(
A int,
b int
)
select * from #T
Insert into #T (A) values (12)
Insert into #T (A) values (12)
Insert into #T (A) values (12)
select * from #T
select count(*) from tempdb..syscolumns where id = object_id('#T')
Hi ,Chris Hedgate
I want this because
I have a row of data and i want all the columns of this records to be under one header.
Fo i need to loop from 1 to Total number columns to select each column value
and insert it into one column.
Pavas
Dream The Dream
Explore the World
Experince The Exhilaration
July 4, 2005 at 1:47 am
I got the solution.
We can get the number of columns by usifn the below line of code.
SELECT COUNT(*) FROM tempdb.dbo.syscolumns WHERE [id] = object_id('tempdb.dbo.#T')
Pavas
Dream The Dream
Explore the World
Experince The Exhilaration
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply