sql server - SQL Concat field from multiple rows -


I would like to create a function that gives the given string of given fields in a given query. Here is what I did. And this gives me an error The table variable "@qry" should declare.

Prefix function dbo.testing (@qry varchar (1000), @fld varchar (100) create, @separtator varchar (15) = ';') back to varchar form Initial announcement @rslt varchar (1000) set @rslt = '' @rslt Select = @rslt + @separator + varchar (160 as cast (@fld)) @qry returns @ Rslt END

What I am trying to do is pass this query to a query and receives a stored string for certain fields of the query.

Is this possible?

What I'm doing wrong

Edit: BTW I have MSSQL Server 2005,

You can not trust FROM @ You need to use dynamic SQL and make your cookie a derived table or something of that nature. However, I think that is not really the best way to believe I believe this is what you are trying to do:

Comments are also optional for XML Be sure to also read on the solution.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -