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
 update additional note

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-11-13 : 21:28:59
how can i update email address which is nvarchar(200) to add in additional date and notes?
Example: abc@yahoo.com update to abc_NEW20121114@yahoo.com
I tried as below but hit this error 'Conversion failed when converting date and/or time from character string'

DECLARE @email nvarchar(200)
DECLARE @date datetime
SET @userName= 'abc@yahoo.com'
SET @date= GETDATE()
Update tableA
set email= @userName+@date
where email= @userName

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-11-13 : 21:47:23
[code]SET email= stuff(@userName, charindex('@', @userName), 0, '_NEW' + convert(varchar(10), @date, 112))[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -