Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Running a SQL query - table include FROM and TO columns

 
   Database Help (Home) -> Datamining RSS
Next:  using UDT for datamining  
Author Message
SoxFanInVA

External


Since: Mar 28, 2008
Posts: 2



(Msg. 1) Posted: Fri Mar 28, 2008 12:12 pm
Post subject: Running a SQL query - table include FROM and TO columns
Archived from groups: microsoft>public>sqlserver>datamining (more info?)

I am trying to export some calendar data from a sql table. This table has 2
column names "from" and "to" for the time range of the appointment. When I
run the sql query:
select date, from, to, act_code, mat_code, clt_code, notes, descrips,
atty_list from appoint where atty_list like '%xxx%'
I get an error. I'm assuming it's because "from" and "to" are sql commands
and doesn't recognize them as column headers? How do I extract the data
from those columns and trick the query into thinking those are not sql
commands?

Thanks,
Tom

 >> Stay informed about: Running a SQL query - table include FROM and TO columns 
Back to top
Login to vote
Jesse

External


Since: May 04, 2007
Posts: 1



(Msg. 2) Posted: Sat Mar 29, 2008 3:55 pm
Post subject: Re: Running a SQL query - table include FROM and TO columns [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mar 28, 9:12 am, "SoxFanInVA"
wrote:
> I am trying to export some calendar data from a sql table. This table has 2
> column names "from" and "to" for the time range of the appointment. When I
> run the sql query:
> select date, from, to, act_code, mat_code, clt_code, notes, descrips,
> atty_list from appoint where atty_list like '%xxx%'
> I get an error. I'm assuming it's because "from" and "to" are sql commands
> and doesn't recognize them as column headers? How do I extract the data
> from those columns and trick the query into thinking those are not sql
> commands?
>
> Thanks,
> Tom

wrap the reserved words in square brackets:

select [to], [from] from mytable

also it's bad practice to use reserved words in your object names, for
exactly this reason.

 >> Stay informed about: Running a SQL query - table include FROM and TO columns 
Back to top
Login to vote
SoxFanInVA

External


Since: Mar 28, 2008
Posts: 2



(Msg. 3) Posted: Tue Apr 08, 2008 2:10 pm
Post subject: Re: Running a SQL query - table include FROM and TO columns [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks Jesse, that is a helpful tip that I didn't see in my SQL cheat sheet.

This isn't a database I created nor am I in a position to edit it so we are
stuck with what we have. We rarely use any custom sql queries and I'm the
only one doing so. So it's not a big deal at the moment.

Thanks,
T

"Jesse" wrote in message

> On Mar 28, 9:12 am, "SoxFanInVA"
> wrote:
>> I am trying to export some calendar data from a sql table. This table
>> has 2
>> column names "from" and "to" for the time range of the appointment. When
>> I
>> run the sql query:
>> select date, from, to, act_code, mat_code, clt_code, notes, descrips,
>> atty_list from appoint where atty_list like '%xxx%'
>> I get an error. I'm assuming it's because "from" and "to" are sql
>> commands
>> and doesn't recognize them as column headers? How do I extract the data
>> from those columns and trick the query into thinking those are not sql
>> commands?
>>
>> Thanks,
>> Tom
>
> wrap the reserved words in square brackets:
>
> select [to], [from] from mytable
>
> also it's bad practice to use reserved words in your object names, for
> exactly this reason.
 >> Stay informed about: Running a SQL query - table include FROM and TO columns 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Select table name - How can I select 'table name' in select clause if I use UNION ALL? Example: select * from table1 union all select * from table2 union all select * from table3 Now I want to see the tablename from where I'll get data. Ex: select...

Trying to cut down query times - I have a query that is based on two other queries that are based on tables in a database. All of the queries that are used for this final query use grouping and totals. In the application I am making, I need to choose a date range to select the subset....

Help w/query pls - Hi, I need to display on a monthly basis the policies sold showing the results in a row from their start date to the end date based on the following data: policy_cost, date_start and date_end Column one should display the first month (date_start)....

How to do updates upon the query results - Hello, I've run a complex SELECT statement combined of the several tables, which returns me: MemberID MemberName CurrentWeightAvailableOn010108 NeedsToHaveWeightOnDate Modifier(NeedsToHaveWeight-CurrentWeightAvailable) 1 John Doe ...

singleton query agains OLAP based model? - Hi, I have created a decision tree DM model from a cube. now I try the singleton query, but how to create the query???? the only samples I found works against an RDBMS model. so I'm not sure how to write my query: SELECT flattened [Test Dec..
   Database Help (Home) -> Datamining All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]