3 pages: [1] [2] [3]
HostWeb Forums » Microsoft Databases » microsoft.public.sqlserver.datamining » Running a SQL query - table include FROM and TO columns

Topic: Running a SQL query - table include FROM and TO columns

Reply | New Topic | This is SPAM | This is Offensive

Submitted: 3/28/2008 10:12:35 AM

By: Tom Jubb
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




Replies below ↓

Replies

Reply | New Topic | This is SPAM | This is Offensive

Submitted: 3/28/2008 10:12:35 AM

By: Tom Jubb

Running a SQL query - table include FROM and TO columns

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




Reply | New Topic | This is SPAM | This is Offensive

Submitted: 3/28/2008 10:12:35 AM

By: Tom Jubb

Running a SQL query - table include FROM and TO columns

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




Reply | New Topic | This is SPAM | This is Offensive

Submitted: 3/28/2008 10:12:35 AM

By: Tom Jubb

Running a SQL query - table include FROM and TO columns

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




Reply | New Topic | This is SPAM | This is Offensive

Submitted: 4/8/2008 12:10:17 PM

By: Tom Jubb

Re: Running a SQL query - table include FROM and TO columns

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" <google@jessehersch.fastmail.fm> wrote in message
news:f52c14f3-bc6a-4fb1-afc5-b13881205ad2@d4g2000prg.googlegroups.com...
> On Mar 28, 9:12 am, "SoxFanInVA" <tj...@no.spamsalot.hotmail.com>
> 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.



Contents
Home
Forums
About Us
Contact Us
Web Hosting:
Hosting Providers
How to choose a name
What is a Hosting Provider
Hosting Types
Choosing the right plan
 
Search
 
Login to HostWeb.com
Email
Password
If you do not have an account with us yet, join now - it's FREE!