Thursday, March 8, 2012

columns in select list

In your client, sure -- every client library can do that. In SQL Server, probably not. What is the business or technical problem you're trying to solve? Perhaps we can come up with a better way of handling it. -- Adam MachanicSQL Server MVPhttp://www.datamanipulation.net-- <buragohain@.discussions.microsoft.com> wrote in message news:6926c563-86b6-40a5-a3f0-3bc32f8e9e94@.discussions.microsoft.com... hi friends!Suppose, i have a query:SELECT fname AS Firstname, lname AS Lastname FROM CustomerNow is it possible to get the column names produced by the above query? LikeFirstnameLastnamejust like we extract column names from information_schema.columns for a table name?with regards,Buragohain

hi friends!

Suppose, i have a query:

SELECT fname AS Firstname, lname AS Lastname FROM Customer

Now is it possible to get the column names produced by the above query? Like

Firstname
Lastname

just like we extract column names from information_schema.columns for a table name?

with regards,
Buragohain

|||What are you consuming it with? ADO with vb? ado.net ?
|||Hi friends!
Thanx everyone for your response.

By creating a temporary table using the query, then accessing the columns, and then deleting the temporary table, will solve the problem. But i wonder is there any in-built technique is Sql server for that or not. Like:

exec sp_columns 'Customer'

exec sp_columns 'select * from Customer' (wrong)

exec sp_columns 'SELECT fname AS Firstname, lname AS Lastname FROM Customer' (wrong)

Again, if there is any technique in ADO.NET, then it will be helpfull too.

(my problem was to show friendly column names to end user from several tables joined.)

with regards,

No comments:

Post a Comment