How to add text to a column select statement

I want to add text to sql select,

I can do it:

SELECT (1328724983-time)/60/60 AS status FROM voting WHERE account = 'ThElitEyeS' AND vid = 1 

This will show the remaining time.

What I would like to do is:

 SELECT 'Please try after' + (1328724983-time)/60/60 AS status FROM voting WHERE account = 'ThElitEyeS' AND vid = 1 

Is there any way to do this?

+4
source share
2 answers

Just use cast or convert to convert it all to varchar for example.

 SELECT 'Please try after' + CAST((1328724983-time)/60/60 as varchar(80)) AS status FROM voting WHERE account = 'ThElitEyeS' AND vid = 1; 

See MSDN for translation / conversion

Based on your comments, you can:

SELECT 'Please try again after' + CAST(MyColForHours as varchar(25)) + ' hours', AnyOtherColumns FROM Table

+13
source

Tried this today and got an error

SQL0420N Invalid character found in the character string argument of the "DECFLOAT" function. SQLSTATE = 22018

Apparently now we need to use || instead of + to join sections.

http://www-01.ibm.com/support/docview.wss?uid=swg21448700

+2
source

Source: https://habr.com/ru/post/1395471/


All Articles