ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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
 Question Submitted By :: K L Baiju
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
create procedure loopcure
as
BEGIN
declare @a int, @b  varchar(020), @l int, @c  varchar(020),
@D  varchar(020)
SET @D  = ''
declare  loopcur cursor for select id from names 
open loopcur
fetch next from  loopcur into @b
while @@fetch_status = 0
begin
select @C = LTRIM(RTRIM(@B)) + ',' 
select @D = LTRIM(RTRIM(@D)) + LTRIM(RTRIM(@C)) 
fetch next from  loopcur into @b
end
close loopcur
deallocate loopcur
select @d = left(@d,  len(@d)-1 )
select @d as final
END
 
Is This Answer Correct ?    3 Yes 0 No
Prasanna
 
  Re: 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
# 2
Hi Friend,

If u use SQLSERVER 2005 u can try like this............

CREATE TABLE EMP ( ENAME VARCHAR(25))

INSERT INTO EMP VALUES('Ganesh')
INSERT INTO EMP VALUES('Narendra')
INSERT INTO EMP VALUES('Rinku')
INSERT INTO EMP VALUES('Selvam')
INSERT INTO EMP VALUES('Kirti')

SELECT REPLACE(REPLACE( 
 ( SELECT ENAME AS EmpName FROM EMP FOR XML PATH ('') ) ,'<EmpName>',''),'</EmpName>',',')
 
Is This Answer Correct ?    5 Yes 0 No
Soorai Ganesh
 
 
 
  Re: 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
# 3
DECLARE @chrString as varchar(200)

select @chrString=@chrString + ',' + Name from Names

? @chrString
 
Is This Answer Correct ?    1 Yes 1 No
Kulwinder
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
I am having table Title with TITLE id,Author ID, Publiser ID , table AUTHOR with Author ID, Author Name, table PUBLISER with Pub ID, Pub name Here hot to find out the publiser id who have relesed the books of patriticular author?  3
hi i gone though satyam interview. what is Acid Properties? Satyam2
What are the different types of joins and what does each do?  2
How the data stores in a page?  1
What is the purpose of UPDATE STATISTICS?  1
Difference between Triggers and Stored Procedure Protech9
what is difference between nchar and char in Sql server ?  2
how can do you the system monitoring?  1
What is a deadlock and what is a live lock? How will you go about resolving deadlocks? Microsoft1
What are SQL Jobs, please mention the use of it and how to create them. 247Customer1
Is it possible to create a stored procedure that runs a query and outputs the results to a text file and allows me to add extra delimeters and static field info. If so How?  1
Explain the architecture of SQL Server?  2
What value could be assigned to Varchar Type?  3
what is index seek and index scan?  2
Hi Friends, I have a table in which there are thousands of records and in city field there is NULL value for all records now i want to change that null value with distinct values in each record say delhi, bihar, agra, jaipur etc, what will be the query for that????? its not possible to update thousands of records one by one. is there any alternative ...? Plz help ... its urgent Thanx in advance  1
how to dispaly a particular row details from a given table  1
How many max. conditions can b written under the WHERE clause? Like select * from [tabnam] WHERE (cond1...or..cond2....or...cond3...and.....so on.....??? (upto how much extent))????? SAP-Labs2
how will u create "n" possible tables in sql... Oracle1
How will oyu test the stored procedure taking two parameters namely first name and last name returning full name?  3
what is normalization? what is denormalization? Satyam5
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com