dotnetrockz Posted May 28, 2014 Report Posted May 28, 2014 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?
LungiLingaraju Posted May 28, 2014 Report Posted May 28, 2014 Em error vastundi .. Mostly nuvvu ' single codes dagara tappu jargutundi .. DBMS out put line pettu print chey execute aiyye mundu ..
LungiLingaraju Posted May 28, 2014 Report Posted May 28, 2014 Multiple as single ante .. Select a || b || c as d from e ani aa ???
dotnetrockz Posted May 28, 2014 Author Report Posted May 28, 2014 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'
electionszindabad Posted May 28, 2014 Report Posted May 28, 2014 Multiple as single ante .. Select a || b || c as d from e ani aa ??? use + symbols....
kranthi111 Posted May 28, 2014 Report Posted May 28, 2014 select last_name+'',''+first_name from table
Suhaas Posted May 28, 2014 Report Posted May 28, 2014 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
kranthi111 Posted May 28, 2014 Report Posted May 28, 2014 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..
electionszindabad Posted May 28, 2014 Report Posted May 28, 2014 use this declare @sql varchar(2000) set @sql = 'select col1 +' + 'col2 +' +'col3'+ 'from tablename' print @sql exec (@sql) -- dont forget the parenthesis...
pandugadu999 Posted May 28, 2014 Report Posted May 28, 2014 dynamic sql nerchukodaniki edina source plz..
dotnetrockz Posted May 28, 2014 Author Report Posted May 28, 2014 dynamic sql nerchukodaniki edina source plz.. http://www.sqlteam.com/article/using-dynamic-sql-in-stored-procedures
Suhaas Posted May 29, 2014 Report Posted May 29, 2014 Neeku em work ayindo post cheyi bhayya. If it's something that you feel can help us in the future.
Recommended Posts