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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cast Update question

Author  Topic 

smorty44
Yak Posting Veteran

93 Posts

Posted - 2007-10-26 : 11:25:43
I have a table that I want to update an nvarchar field that have null records with the account# field that is nvarchar and a date field that is smalldatetime. I am getting an arithematic overflow error due to the smalldatetime field if I don't cast as nvarchar, however, when I cast the date field as nvarchar I get "Feb 03 2007". I need this field to return the same as it shows in the date column of 20070203. Is this possible? Here is my sql statement:

Update tbl_Services
Set TicketNum = account + Cast(date as nvarchar)

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-26 : 11:35:58
Make use of CONVERT instead of CAST with ISO date format i.e. 112

Update tbl_Services
Set TicketNum = account + Convert(nvarchar(10),date,112)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -