Hi all,
is it possible to print the results in comma seprated text.
i.e
col1
--
Jhon
Henery
should be displayed as Jhon,Henery
Is possble to display the results in single select statement?.
RegardsPreveen
Yes , it is. But I would recommend you doing such things on the client.
CREATE TABLE #Test
(
col VARCHAR(20) NOT NULL
)
INSERT INTO #Test VALUES ('Bill')
INSERT INTO #Test VALUES ('Clinton')
DECLARE @.p VARCHAR(50)
SET @.p=''
SELECT @.p=@.p+col+',' FROM #Test
SELECT LEFT(@.p,LEN(@.P)-1)
"Praveen" <apveen@.gmail.com> wrote in message
news:1127390507.779755.291720@.g43g2000cwa.googlegroups.com...
> Hi all,
> is it possible to print the results in comma seprated text.
> i.e
> col1
> --
> Jhon
> Henery
> should be displayed as Jhon,Henery
> Is possble to display the results in single select statement?.
> Regards
>|||It's possible... but you're better off doing this client side.
In ASP you can use GetString()
"Praveen" <apveen@.gmail.com> wrote in message
news:1127390507.779755.291720@.g43g2000cwa.googlegroups.com...
> Hi all,
> is it possible to print the results in comma seprated text.
> i.e
> col1
> --
> Jhon
> Henery
> should be displayed as Jhon,Henery
> Is possble to display the results in single select statement?.
> Regards
>|||A SELECT statement doesn't control how text is printed. A SELECT statement
just returns a result set. How you print or display that result is determine
d
by your client application.
In your case, if you do this in SQL how do you expect to determine which
value to display first and second? Here's one possibility:
SELECT MAX(col1)+','+MIN(col1)
FROM some_table ;
David Portas
SQL Server MVP
--
Showing posts with label seprated. Show all posts
Showing posts with label seprated. Show all posts
Subscribe to:
Posts (Atom)