Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Merge the three fields of table into single field without using Concatenation function in sql.

user-image
Question ajoutée par muthiah m
Date de publication: 2014/02/05
Mohammad Masadeh
par Mohammad Masadeh , SharePoint Lead Developer , Port Customs And Freezone Corporation Dubai

In oracle we do it like this  

select field1 || field2 || field3 as result from tablename;

Ex : select ' current time is '|| sysdate from dual ;

u can use this sytanx in concatenation  fieds

Use AS

Select Field1,Field2,Field3 As filedMerge

Muhamamd Saqib
par Muhamamd Saqib , Senior Software Engineer / Technical Lead , OT EMR Inc.

Use a function with COALESCE.

 

CREATE FUNCTION [GetFieldsWithID](    @id int)RETURNS varchar(max)ASBEGIN    declare @output varchar(max)    select @output = COALESCE(@output + ', ', '') + alias    from Users    where id = @id    return @outputENDGOSELECT [id], GetFieldsWithID([id])FROM UsersGO

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?