SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 error: incorrect syntax near '-'. why?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shoxxbinoxx
Starting Member

2 Posts

Posted - 08/17/2010 :  16:39:15  Show Profile  Reply with Quote
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

Sweden
30178 Posts

Posted - 08/17/2010 :  16:43:26  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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 - 08/17/2010 :  16:47:15  Show Profile  Reply with Quote
thank you!
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22754 Posts

Posted - 08/18/2010 :  11:19:56  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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 - 08/18/2010 :  11:39:44  Show Profile  Reply with Quote
<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
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 08/18/2010 :  15:08:20  Show Profile  Reply with Quote
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)

Singapore
17595 Posts

Posted - 08/18/2010 :  23:13:41  Show Profile  Reply with Quote
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
Time is always against us

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30178 Posts

Posted - 08/19/2010 :  03:23:05  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

United Kingdom
22403 Posts

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

SwePeso
Patron Saint of Lost Yaks

Sweden
30178 Posts

Posted - 08/19/2010 :  06:20:45  Show Profile  Visit SwePeso's Homepage  Reply with Quote
The benefit of creating tables with dynamic sql code...



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000