How to insert minus sign (-) into column field

I know that this may be a simple question, but I am not too familiar with SQL and have not been able to find a solution.  In a SQL 2005 Database table, I am trying to update a column field with a '-'.

As an example, I want to fill the column field 'code' with '12345-6789'.  The problem is that when I attempt to do this, the SQL Query sees this as a request for the difference of the 2 numbers (12345 - 6789 = 5556), resulting in a field value of 5556.

Is there anyway to add the '-' into the column field, without having it subtract the values before and after it?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

select cast(1234 as varchar(4)) + '-' + cast(342 as varchar(3)) from tablename
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you have to use single quotes to delimit the string:

UPDATE yourtable
  SET yourfield = '12345-6789'
 WHERE ...

instead of:

UPDATE yourtable
  SET yourfield = 12345-6789
 WHERE ...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Change your column datatype to varchar
update table_name
set code = col1 + '-' + col2
where <your_condiontion>

try this
moonraker12Author Commented:

That worked perfectly.  I ran:

update table
set column = '12345-6789'

and got the desired outcome.

Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.