SQL Server 2005 中如何将单行转换为列 [英] how to convert a single row into Column in SQL Server 2005

查看:32
本文介绍了SQL Server 2005 中如何将单行转换为列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,它返回的数据为 -

I have a table, and it is returning the data as -

Column1  Column2    Column3   Column4   Column5   Column6
-------------------------------------------------------------------
6        Joy        Mycity    NZ        123456    myemail@gamil.com

我需要将其显示为 -

SingleColumn
-----------------------
6
joy
mycity
NZ
123456
myemail@gmail.com

我该怎么做?

推荐答案

我会让查询继续返回当前的数据,作为单独的列,而不是根据需要设置 UI 代码格式.使其更加灵活,因此您可以对相同的数据进行 x 次不同的显示,所有这些都使用与数据源相同的查询.

I'd make the query continue to return the data as you currently are, as individual columns, and instead make the UI code format it as it needs it. Makes it more flexible so you can have x different displays of the same data, all using the one, same query as the data source.

这篇关于SQL Server 2005 中如何将单行转换为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆