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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Add a column in one the excels sheet using SQL

Author  Topic 

ihuda
Starting Member

2 Posts

Posted - 2014-07-10 : 17:30:01
I just started using SQL. I have excel document with 20 different sheets, each sheet at least has 15 columns in it. I have to add a new column in one of the excel sheet using SQL(all database is in sql). I am using
ALTER TABLE table_name
ADD column_name datatype
but it comes back and gives me syntax error.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-10 : 17:35:11
Show us the exact command and the error.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2014-07-11 : 01:49:46
You can complete the task using powershell - it's useful for Excel sheet object management

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

ihuda
Starting Member

2 Posts

Posted - 2014-07-11 : 15:33:53
I am writing the following commands:
"ALTER TABLE Active Power Battery
ADD Voltage Integer"
and its gives me the following error:
[Microsfot][ODBC SQL Server Driver][SQL Server]Incorrect syntax near'Power'
and after clicking ok, it says
[Microsfot][ODBC SQL Server Driver][SQL Server]Incorrect syntax near'Voltage'

@ Jacky: I will do my research on powershell.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-11 : 15:42:33
You need to put square brackets around the table name and column name. I would seriously reconsider having spaces in object names!

[square brackets for object names with spaces]

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-11 : 15:46:29
You also need to add the data type.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -