Showing posts with label tablesfor. Show all posts
Showing posts with label tablesfor. Show all posts

Thursday, March 8, 2012

columns count

Please any one can tell me.
How to defined Number of columns for tables?
For example I have one table in my database called “my_table” it has number of columns
What the functions or any thing I can use to get the number of columns for that table and assigned to local variable?
Declare @.P_count_int
Select @. P_count_int = ??
If this table (my_table have 5 columns )
The result should be if I print this variable 5
SELECT @.p_count_int = COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='my_table'
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"mmsjed" <anonymous@.discussions.microsoft.com> wrote in message
news:D1CFBD6D-9872-4B36-89A7-944CB9A9B396@.microsoft.com...
> Please any one can tell me.
> How to defined Number of columns for tables?
> For example I have one table in my database called my_table it has
> number of columns
> What the functions or any thing I can use to get the number of columns for
> that table and assigned to local variable?
> Declare @.P_count_int
> Select @. P_count_int = ??
> If this table (my_table have 5 columns )
> The result should be if I print this variable 5
>

columns count

Please any one can tell me.
How to defined Number of columns for tables?
For example I have one table in my database called “my_table” it has num
ber of columns
What the functions or any thing I can use to get the number of columns for t
hat table and assigned to local variable?
Declare @.P_count_int
Select @. P_count_int = '?
If this table (my_table have 5 columns )
The result should be if I print this variable 5SELECT @.p_count_int = COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='my_table'
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"mmsjed" <anonymous@.discussions.microsoft.com> wrote in message
news:D1CFBD6D-9872-4B36-89A7-944CB9A9B396@.microsoft.com...
> Please any one can tell me.
> How to defined Number of columns for tables?
> For example I have one table in my database called my_table it has
> number of columns
> What the functions or any thing I can use to get the number of columns for
> that table and assigned to local variable?
> Declare @.P_count_int
> Select @. P_count_int = '?
> If this table (my_table have 5 columns )
> The result should be if I print this variable 5
>