there is a table having two columns no and name
and the data is
1 A
2 B
3 C
write a query that will result a horizontal output
A,B,C
Answer Posted / utsav
declare @tst varchar(max)
set @tst=''
select @tst=@tst+col+',' from table
select @tst
there is a twist, if col contains any null value then this
query will return null. use isnull(col,'') in that case
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
List some advantages and disadvantages of stored procedure?
You want to check the syntax of a complicated update sql statement without executing it. What command should you use?
What is the difference between having clause and where clause in sql server?
What is an active database?
How can we use ConnectorJ JDBC Driver with MS SQL?
What are sql azure firewall rules?
What is index, cluster index and nonclustered index?
How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?
What is data file in computer?
Does full backup break log chain?
Stored Procedure returns data from multiple tables. How to access it in your ASP.Net code?
What are the advantages of the mirroring?
What is row_number () and partition by in sql server?
What is SQL Server?
How to create a local temporary stored procedure?