[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

weird issue with UPDATE

Posted on 2007-10-05
2
Medium Priority
?
237 Views
Last Modified: 2010-03-19
i'm trying to just run a very simple update on a date field in 1 table. i have a datetime field called 1stLetter in a table called _Prospects. so i try

Update _Prospects Set 1stLetter = '1/1/2006' Where ID = 1617

and i get the error "Incorrect syntax near '1'." and i know it's talking about the 1 in '1stLetter' because i have 2 other date fields called 2ndLetter and 3rdLetter and trying each of those gives me errors on 2 and 3 respectively. what the heck is going on?
0
Comment
Question by:craskin
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1200 total points
ID: 20023780
Update _Prospects Set [1stLetter] = '1/1/2006' Where ID = 1617
0
 
LVL 27

Expert Comment

by:ptjcb
ID: 20023816
Do this instead:

Update _Prospects
Set [1stLetter] = '1/1/2006'
Where ID = 1617


Identifiers in SQL

The rules for the format of regular identifiers depend on the database compatibility level. This level can be set by using sp_dbcmptlevel. When the compatibility level is 90, the following rules apply:

The first character must be one of the following:


A letter as defined by the Unicode Standard 3.2. The Unicode definition of letters includes Latin characters from a through z, from A through Z, and also letter characters from other languages.


The underscore (_), at sign (@), or number sign (#).

Certain symbols at the beginning of an identifier have special meaning in SQL Server. A regular identifier that starts with the at sign always denotes a local variable or parameter and cannot be used as the name of any other type of object. An identifier that starts with a number sign denotes a temporary table or procedure. An identifier that starts with double number signs (##) denotes a global temporary object. Although the number sign or double number sign characters can be used to begin the names of other types of objects, we do not recommend this practice.

Some Transact-SQL functions have names that start with double at signs (@@). To avoid confusion with these functions, you should not use names that start with @@.


Subsequent characters can include the following:


Letters as defined in the Unicode Standard 3.2.


Decimal numbers from either Basic Latin or other national scripts.


The at sign, dollar sign ($), number sign, or underscore.


The identifier must not be a Transact-SQL reserved word. SQL Server reserves both the uppercase and lowercase versions of reserved words.


Embedded spaces or special characters are not allowed.


Supplementary characters are not allowed.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question