Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 error: incorrect syntax near '-'. why?

Author  Topic 

shoxxbinoxx
Starting Member

2 Posts

Posted - 2010-08-17 : 16:39:15
I am trying to insert all of the data from one table into another by using the following query:

INSERT INTO LeadTemplate (phone, firstname, lastname, address, city, state, zip, e-mail, eventname, eventdate)
SELECT *
FROM _tempImport

when i try to parse the query i get "Line 1: Incorrect syntax near '-'." I have already checked to make sure the column name in LeadTemplate is "e-mail" with the dash in it. Does anyone know whats causing this error?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-17 : 16:43:26
INSERT INTO LeadTemplate (phone, firstname, lastname, address, city, state, zip, [e-mail], eventname, eventdate)
SELECT *
FROM _tempImport


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

shoxxbinoxx
Starting Member

2 Posts

Posted - 2010-08-17 : 16:47:15
thank you!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-08-18 : 11:19:56
It is better to make use of underscore (_) instead of hephen (-)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-08-18 : 11:39:44
<biatch slap>

quote:
Originally posted by Peso

INSERT INTO LeadTemplate (phone, firstname, lastname, address, city, state, zip, [e-mail], eventname, eventdate)
SELECT *
FROM _tempImport


N 56°04'39.26"
E 12°55'05.63"




</biatch slap>


INSERT INTO LeadTemplate (
phone, firstname, lastname, address, city, state, zip, [e-mail], eventname, eventdate)
SELECT phone, firstname, lastname, address, city, state, zip, [e-mail], eventname, eventdate
FROM [_tempImport]




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-08-18 : 15:08:20
quote:
Originally posted by X002548

FROM [_tempImport]



Why the square brackets around the table name?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-08-18 : 23:13:41
quote:
Originally posted by Lamprey

quote:
Originally posted by X002548

FROM [_tempImport]



Why the square brackets around the table name?


It is not a must, but probably just a personal taste or weird to see a table name prefix with a "_"


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-19 : 03:23:05
Better a underscore than a space! Took me a while to find that out with another problem...



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-08-19 : 03:59:14
Table name STARTED with a space? I could use that ...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-19 : 06:20:45
The benefit of creating tables with dynamic sql code...



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -