How to combine string data with table column for SQL Query
Would it be possible to combine string data with table column in SQL Server Query. For example: DB name = soundsDB DB table = soundtype inside soundtype table: type, que Problems: Is it possible to combine 'Sing' and que using below query: case when type='1' then 'Sing- ' else 'Silence - ' End as DESCRIPTIONS Please advise. Thank you.
Yes, you can do that. It would look something like this: SELECT CASE WHEN type = '1' THEN 'Sing-' + que ELSE 'Silence-' + que END AS Descriptions FROM dbo.SoundType; NOTE: This example is assuming that the [que] column is a string data type. If it's not, you'll have to CAST/CONVERT it to be a string for the concatenation to work correctly. Hope that helps!