hi,
i have a table called names and field name
select * from names
name
a
b
c
d
i want to display like this
name
a,b,c,d
how it is possible
Regards
Baiju
Answer Posted / gopi muluka
CREATE TABLE Names (Name VARCHAR(50))
GO
INSERT Names
SELECT 'A'
UNION
SELECT 'B'
UNION
SELECT 'C'
UNION
SELECT 'D'
GO
-- FIRST METHOD
DECLARE @Name VARCHAR(50)
SELECT @Name=ISNULL(@Name,'')+ COALESCE(Name,',')+',' FROM
Names
SELECT LEFT(@Name,LEN(@Name)-1)
GO
--SECOND METHOD
DECLARE @chrString as varchar(200)
SET @chrString=''
SELECT @chrString=@chrString + ',' + Name FROM Names
SELECT SUBSTRING(@chrString,2, LEN(@chrString))
GO
DROP TABLE Names
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the purpose of linked server configuration in sql server?
What is trigger explain with program?
What is difference between order by and group by?
Explain what is cte (common table expression)?
What is "scheduled jobs" or "scheduled tasks"?
How many categories of data types used by sql server?
What methods do you follow to protect from sql injection attack?
what is denormalization? : Sql server database administration
Explain nested trigger in sql?
What are the five characteristics of good data?
Explain syntax for dropping triggers?
Describe in brief databases and sql server databases architecture.
Define magic tables in sql server?
let's assume you have data that resides on sql server 6.5. You have to move it sql server 7.0. How are you going to do it? : Sql server database administration
how you can deploy an ssrs report?