Tuesday, March 6, 2012

about tsql

in tsql,how can select the data rely on the column order
,not the column name
such as
select column1,column2
from...You may need to pur like this ... select col1,col2 from
table name order by 1,2
Hope, I understood the question correctly.
Suresh
>--Original Message--
>in tsql,how can select the data rely on the column order
>,not the column name
>such as
>select column1,column2
>from...
>.
>|||Why would you want to do this' If you could state your problem, maybe we
can give you an alternate solution.
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp
"frank" <anonymous@.discussions.microsoft.com> wrote in message
news:010a01c3b89d$430c9460$a001280a@.phx.gbl...
> in tsql,how can select the data rely on the column order
> ,not the column name
> such as
> select column1,column2
> from...
>|||i want to get several tables' first column's data
and the table name store in one table, and of course the
table's first column's name is different
in short
i want use a loop update several table's first column
>--Original Message--
>Why would you want to do this' If you could state your
problem, maybe we
>can give you an alternate solution.
>--
>HTH,
>SriSamp
>Please reply to the whole group only!
>http://www32.brinkster.com/srisamp
>"frank" <anonymous@.discussions.microsoft.com> wrote in
message
>news:010a01c3b89d$430c9460$a001280a@.phx.gbl...
>> in tsql,how can select the data rely on the column order
>> ,not the column name
>> such as
>> select column1,column2
>> from...
>
>.
>|||In the SQL language, you refer to columns by name, not position. There are two exceptions: "SELECT
*" and INSERT without a column name list.
You can use the INFORMATION_SCHEMA views to read each table name and the name of the first column
name. And based on that, you can construct your SQL statement and run that through dynamic SQL (EXEC
@.sql). The info schema views are documented in Books Online and I've done a diagram of them at
http://www.dbmaint.com/info_schema.asp.
You can find a lot of info on dynamic SQL at:
http://www.algonet.se/~sommar/
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"frank" <anonymous@.discussions.microsoft.com> wrote in message
news:083801c3b8bb$29ff2cd0$a501280a@.phx.gbl...
> i want to get several tables' first column's data
> and the table name store in one table, and of course the
> table's first column's name is different
> in short
> i want use a loop update several table's first column
>
>
> >--Original Message--
> >Why would you want to do this' If you could state your
> problem, maybe we
> >can give you an alternate solution.
> >--
> >HTH,
> >SriSamp
> >Please reply to the whole group only!
> >http://www32.brinkster.com/srisamp
> >
> >"frank" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:010a01c3b89d$430c9460$a001280a@.phx.gbl...
> >> in tsql,how can select the data rely on the column order
> >> ,not the column name
> >>
> >> such as
> >> select column1,column2
> >> from...
> >>
> >
> >
> >.
> >|||>--Original Message--
>In the SQL language, you refer to columns by name, not
position. There are two exceptions: "SELECT
>*" and INSERT without a column name list.
thanks a lot
>You can use the INFORMATION_SCHEMA views to read each
table name and the name of the first column
>name. And based on that, you can construct your SQL
statement and run that through dynamic SQL (EXEC
>@.sql). The info schema views are documented in Books
Online and I've done a diagram of them at
>http://www.dbmaint.com/info_schema.asp.
>You can find a lot of info on dynamic SQL at:
>http://www.algonet.se/~sommar/
>--
>Tibor Karaszi, SQL Server MVP
>Archive at: http://groups.google.com/groups?
oi=djq&as_ugroup=microsoft.public.sqlserver
>
>"frank" <anonymous@.discussions.microsoft.com> wrote in
message
>news:083801c3b8bb$29ff2cd0$a501280a@.phx.gbl...
>> i want to get several tables' first column's data
>> and the table name store in one table, and of course the
>> table's first column's name is different
>> in short
>> i want use a loop update several table's first column
>>
>>
>> >--Original Message--
>> >Why would you want to do this' If you could state your
>> problem, maybe we
>> >can give you an alternate solution.
>> >--
>> >HTH,
>> >SriSamp
>> >Please reply to the whole group only!
>> >http://www32.brinkster.com/srisamp
>> >
>> >"frank" <anonymous@.discussions.microsoft.com> wrote in
>> message
>> >news:010a01c3b89d$430c9460$a001280a@.phx.gbl...
>> >> in tsql,how can select the data rely on the column
order
>> >> ,not the column name
>> >>
>> >> such as
>> >> select column1,column2
>> >> from...
>> >>
>> >
>> >
>> >.
>> >
>
>.
>

No comments:

Post a Comment