Jump to content

Recommended Posts

Posted

im changing an existing stored proc

 

joing it with a new table

 

and in the select clause i want to select multiple column values as single value(like name,city,ph num)---all these values are in the table i joined....

 

with normal sql its easy but dynamic sql im getting syntax errors.....does anyone have the syntax to select multiple columns as single value in dynamic sql?

 

Posted

Em error vastundi .. Mostly nuvvu ' single codes dagara tappu jargutundi .. DBMS out put line pettu print chey execute aiyye mundu ..

Posted

Multiple as single ante .. Select a || b || c as d from e ani aa ???

Posted

Multiple as single ante .. Select a || b || c as d from e ani aa ???

SELECT Last_name+','+First_name+'-'+City+','+Office_phone+','+department

FROM user_info

WHERE USER_ID='test'

Posted

Multiple as single ante .. Select a || b || c as d from e ani aa ???

use + symbols.... 

Posted

aa fields ni mundhe add chesi oka variable lo pettukovachukada  appudu koncham clean ga avuthundemo...not sure if this is waht you are asking for...

 

declare @tableName varchar(100)
declare @sqlQuery  varchar(max)
declare @fields varchar(max)
set @tableName = 'TablName'
set @fields = ''
select @fields = @fields + QUOTENAME(t.fieldname) + ','
set @sqlQuery = 'select ' + left(@fields, LEN(@fields)-1) + ' from ' + QUOTENAME(@tableName)
execute sp_executesql @sqlQuery

Posted

SELECT Last_name+','+First_name+'-'+City+','+Office_phone+','+department

FROM user_info

WHERE USER_ID='test'

 

aa single quotes daggara inko quote add chey.. it should work..

Posted

use this

 

declare @sql varchar(2000)

set @sql = 'select col1 +' + 'col2 +' +'col3'+  'from tablename'

print @sql

exec (@sql) -- dont forget the parenthesis...

Posted

dynamic sql nerchukodaniki edina  source plz..

Posted

Neeku em work ayindo post cheyi bhayya. If it's something that you feel can help us in the future.

×
×
  • Create New...