sql - How to set a cast value in a bracket? -
i trying cast 2 datas. want cast data within bracket. have tried this:
select empcode, (cast(name varchar(50))+' '+cast(empcode varchar(50))) name shiftallocation
it gives output name , empcode
tom varghees 12345
but want 12345 (empcode) in bracket. expected output is
tom varghees [12345]
what changes should in sample querym
you can use quotename.
select empcode, (cast(name varchar(50)) + ' ' + quotename(cast(empcode varchar(50)))) name shiftallocation
if don't have ability use quotename
can go in following:
select empcode, (cast(name varchar(50)) + ' [' + cast(empcode varchar(50)) + ']') name shiftallocation
Comments
Post a Comment