SQLTeam.com | Weblogs | Forums

Timestamp in SET statement


#1

Hi,

I am trying to enter a datestamp into a SET statement:
--MY CODE--
Update tbReturns
Set Details='MARKA'+ CHAR(13)+ CHAR(10)+ CONVERT(varchar(max),Details)
Where ID= 16411;

I am trying to enter the timestamp after 'MARKA'

Is this even possible?

Grateful for any help...strong text


#2

What datatype is Details? You do not need to convert it to varchar(max) in the set command as it should already be that to except the new data.

UPDATE tbReturns SET Details = 'MARKA' + CONVERT(VARCHAR(20), GETDATE(), 101) + CHAR(13)+ CHAR(10)+ Details Where ID= 16411;


#3

The Details datatype is just text.

I just want to add a timestamp after the initial text 'MARKA'


#4

If Details is truly TEXT then this will not work. To update a text column you need different commands.

If it is really VARCHAR, NVARCHAR or CHAR my example should work by changing the 101 to the value that gives you what you are looking for say 120.


#5

Thank you for your help Djj55


#6

Glad I could help.