How can I insert "_" into a SQL Server field in a table?

Bill
Bill used Ask the Experts™
on
We have a table that tracks values for Combo Boxes. One field captures the actual name of the Control (cboSVC_AGREE_TYP). The INSERT INTO statement is as follows:

INSERT INTO OBJECT_REFS ( OBJ_TYP, OBJ_NM, OBJ_DESC, OBJ_VALUE, CREATE_BY, CREATE_DT) _
                  Values('Combo Box','cboSVC_AGREE_TYP',' Types of service Agreement','On Call 24-7', 'John Doe',GETDATE())

I get the following error:

sg 102, Level 15, State 1, Line 2
Incorrect syntax near '_'.

Data entry forms reference this table for their values and the Combo Box names match the field name in the applicable tables with the exception of the prefix "cbo"

Thanks for your help


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
SQL Server does not need _ as a line continuator.INSERT INTO OBJECT_REFS ( OBJ_TYP, OBJ_NM, OBJ_DESC, OBJ_VALUE, CREATE_BY, CREATE_DT)                   Values('Combo Box','cboSVC_AGREE_TYP',' Types of service Agreement','On Call 24-7', 'John Doe',GETDATE())
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
_  is not a special character at all, actually... so I wonder why you get that message, unless you have actually missed some quote, for example, some where ...
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
ok, I see now ... matthewspatrick is correct!
Why there is _ coming before 'Values('Combo Box'....' ??

i guess that is the problem what u r facing.. check from where it is appreaing in ur statement..
BillBusiness Systems Analyst

Author

Commented:
The errror is generated when it sees the Value 'cboSVC_AGREE_TYP'
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
no. see here:


INSERT INTO OBJECT_REFS ( OBJ_TYP, OBJ_NM, OBJ_DESC, OBJ_VALUE, CREATE_BY, CREATE_DT) >>>>> _ <<<<< this one. remove that, and it's ok
                  Values('Combo Box','cboSVC_AGREE_TYP',' Types of service Agreement','On Call 24-7', 'John Doe',GETDATE())

Open in new window

BillBusiness Systems Analyst

Author

Commented:
Thanks - I am used to working with PSQL.
Top Expert 2010

Commented:
wvonb,With respect, I had the correct answer in the very first comment: you had an extraneous underscore, and I told you how to fix it.I wouldn't have minded a split, but to get nothing at all strikes me as rather unfair.Patrick
BillBusiness Systems Analyst

Author

Commented:
Patrick,
I thought I awarded points
Top Expert 2010

Commented:
You did, but you gave all 500 to angelIII.  In my opinion, this ought to have been a split.:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial