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.
| Author |
Topic |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2003-01-27 : 23:13:48
|
| I am tryting to create table called Holiday using following script: USE tempdb GO DROP TABLE HOLIDAYS GO CREATE TABLE HOLIDAYS (HolidayName long(30), HolidayDate smalldatetime) INSERT HOLIDAYS VALUES("New Year's Day","19990101") INSERT HOLIDAYS VALUES("Valentine's Day","19990214") INSERT HOLIDAYS VALUES("St. Patrick's Day","19990317") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`~~ But, I am keep getting error message says: Server: Msg 128, Level 15, State 1, Line 3 The name 'New Year's Day' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Can't I use Varchar as a datatype in this situation? Any help would appreciated? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-01-28 : 00:08:13
|
| It is interpreting the values in double quotes as column names/identifiers, not as strings or dates. Strings and dates in SQL Server must be delimited with single quotes ('). If you have embedded apostrophes in the data, you must double them ('') to INSERT them correctly:INSERT HOLIDAYS VALUES('New Year''s Day','19990101') INSERT HOLIDAYS VALUES('Valentine''s Day','19990214') INSERT HOLIDAYS VALUES('St. Patrick''s Day','19990317') |
 |
|
|
|
|
|
|
|