Re: Output Column names in each Row along with the row Value



On Jun 29, 3:09 pm, Yas <yas...@xxxxxxxxx> wrote:
Hello,

I was wondering if anyone can help me figure something out.
Is it possible to do a querey in MS SQL server and have the results
returned so that each result in each row is preceeded by the column
name?

eg. instead of usual output -> colName1, colValue1,
colName2,colValue2,colName3,colValue3 ?

Also I would like to only have this for certain columns ie in the
above example only for columns 2 and 3

Thank you! :-)

Yas

Not sure what you are actually looking at

create table #temp (col1 int, col2 int , col3 varchar(10))
insert into #temp values (1,10,'abcd')
insert into #temp values (2,20,'efgh')


select col1, ' col2:'+cast(col2 as varchar(10))+ '-col3:'+col3 as
col23
from #temp

drop table #temp

.



Relevant Pages

  • Re: T-SQL is not quite there yet
    ... no, the choice is between INSERT-EXEC ... results ought to be called functions, not "stored procedures". ... SQL Server is a server- ... gains only by putting keys on temp tables that had none. ...
    (microsoft.public.sqlserver.programming)
  • Row by Row Operations Help req
    ... Create temp table 1 ... Nigel,The cursor question is the SQL equivalent of the GOTOs / NO GOTOs ... question about whether the familiarity of procedural code is worth the ... leverages the strengths of SQL Server and is usually faster since it uses ...
    (microsoft.public.sqlserver.programming)
  • Re: SYS.SQL_DEPENDENCIES, Refresh Dependencies
    ... because you cannot have temp tables in user-defined functions. ... If you are using dependencies to see what you need to migrate from test ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Help with trigger
    ... You could get the data into temp tables and from these insert into ... of temp tables in triggers. ... running INPUTBUFFER or querying sysprocesses from a trigger. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Temp files in Stored Procedures
    ... locks on the system tables until it is finished it can have an adverse ... SQL Server MVP ... Temp tables created in this manner are ... >>> processes calling your stored procedure and each one would have their ...
    (microsoft.public.sqlserver.programming)