punctuation for SQL Server values

Results 1 to 2 of 2

Thread: punctuation for SQL Server values

  1. #1
    Join Date
    Dec 1969

    Default punctuation for SQL Server values

    I am upgrading to SQL Server, and I need to develop a "cheat sheet" listing the required punctuation for surrounding values that are going to be inserted into various kinds of SQL Server fields. For example, the list in MS Access includes:<BR><BR>DateTime surrounded by # and #<BR>Text Surrounded by &#039; and &#039;<BR>and so on<BR><BR>i have read extensively about SQL Server, and this issue does not seem to be described in any of the resources I have found so far.<BR><BR>the immediate cause of this problem is an error message that I am getting from the following SQL statement when i try to run it in a script connecting to a SQL Server database.<BR>-----------------------------------------------------------------<BR>SQLstatement = "INSERT INTO Sessions (SessionTime_stamp, UserID) " &_<BR> "VALUES ( #" & SessionTime_stamp & "# , " & LoginID & ")"<BR>-----------------------------------------------------------------<BR>the error message that this SQL statement is generating is as follows:<BR>-----------------------------------------------------------------<BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80040e14&#039; <BR><BR>[Microsoft][ODBC SQL Server Driver][SQL Server]The name &#039;#7&#039; is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. <BR><BR>/SQL/login.asp, line 98 <BR>-----------------------------------------------------------------<BR>Assuming that I need to know a new set of punctuation marks for surrounding values-to-be-inserted, i will include a list of SQL Server data types below. please be so kind as to show me which punctuation marks go around which data types. The data type for the column related to the error above is DATETIME<BR>-----------------------------------------------------------------<BR>SQL Server Data Types / Required Punctuation<BR>bigint /<BR>int /<BR>smallint /<BR>tinyint /<BR>bit /<BR>decimal /<BR>numeric /<BR>money /<BR>smallmoney /<BR>float /<BR>real /<BR>datetime /<BR>smalldatetime /<BR>char /<BR>varchar /<BR>text /<BR>nchar /<BR>nvarchar /<BR>ntext /<BR>binary /<BR>varbinary /<BR>image /<BR>cursor /<BR>sql_variant /<BR>table /<BR>timestamp /<BR>uniqueidentifier /

  2. #2
    Join Date
    Dec 1969

    Default RE: punctuation for SQL Server values

    All numbers are passed as is, e.g., SELECT * FROM table where ID = 0<BR><BR>All chars and dates are passed with single quotes<BR><BR>SELECT * FROM table WHERE name = &#039;MyName&#039; and theDate = &#039;7/16/2002&#039;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts