select only field name from information schema [Resolved]

Posted by Shubham under Sql Server on 12/9/2012 | Points: 10 | Views : 2034 | Status : [Member] | Replies : 8
I want to select only specific column name from information_schema
not all column name from information schema

select Column_name from information_schema.columns where table_name= 'table_name'
this query gives all column name from table but i want some specific field from table

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar



Responses

Posted by: Pavanandey on: 12/10/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
select Column_name from information_schema.columns where table_name= 'FD_FoodItems' and Column_name in
('ItemID','ItemName','Description','Price')


You can speciy the Column name as you like...

@Hariinakoti
Select Id,name from information_schema.columns where table_name=.... and Column_name=....

you need to specify the column_name using In, using = you cannot specify more then one Column

Thanks
Pavan Kumar
Mark Answer if this fits the need

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 12/9/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
do you have any specific id for that field?

Thanks & Regards
Hari

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubham on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
bro every column name have specific ordinal_number like :
name-1
id-2
address-3
that is the serial no of column with in table.....



Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pavanandey on: 12/10/2012 [Member] Bronze | Points: 25

Up
0
Down
One thing i dont get here is you are very specfic of a single coloum they why do you want to query the same column name.

select Column_name from information_schema.columns where table_name= 'FD_FoodItems' and Column_name='ItemName'

Thanks
Pavan Kumar
Mark Answer if this fits the need

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubham on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
exactly pavanandey but i want some more field like
its only example
select column_name from ....... where table_name=... and column_name which is i define like name,id, address, pin


Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
Select Id,name from information_schema.columns where table_name=.... and Column_name=....

Thanks & Regards
Hari

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubham on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
I think bro u dont ever use information schema!!!!!

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shubham on: 12/10/2012 [Member] Starter | Points: 25

Up
0
Down
thanks pavan it will work correctly

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Shubham, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response