求一SQL语句,请高手帮忙(100分)

  • 主题发起人 主题发起人 gdsglgq
  • 开始时间 开始时间
G

gdsglgq

Unregistered / Unconfirmed
GUEST, unregistred user!
表1内容:<br>&nbsp; &nbsp; A &nbsp; &nbsp; &nbsp;B &nbsp; &nbsp; &nbsp; C &nbsp; &nbsp; &nbsp; D &nbsp; &nbsp; E &nbsp; ...... &nbsp;<br>&nbsp; &nbsp;值1 &nbsp; &nbsp;值2 &nbsp; &nbsp; 值3 &nbsp; &nbsp; 值4 &nbsp; 值5 &nbsp;......<br>------------<br>要求SQL查询得到如下效果:把表1中的一行数据,作为一列显示出来。<br><br>VALUES<br><br>值1<br>值2<br>值3<br>值4<br>值5
 
--获取表中字段名<br>SELECT <br>a.name FieldName &nbsp;<br>FROM &nbsp;syscolumns &nbsp;a left join systypes b <br>on &nbsp;a.xtype=b.xusertype<br>inner join sysobjects d <br>on a.id=d.id &nbsp;and &nbsp;d.xtype='U' and &nbsp;d.name&lt;&gt;'dtproperties'<br>left join syscomments e<br>on a.cdefault=e.id<br>left join sysproperties g<br>on a.id=g.id AND a.colid = g.smallid<br>where d.name = '表名'<br>order by a.colorder<br><br>再动态生成SQL语句<br>EXEC sp_executesql @SqlText
 
使用什么数据库?<br>字段 A,B,C,D,E 是固定的吗?
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
900
SUNSTONE的Delphi笔记
S
D
回复
0
查看
824
DelphiTeacher的专栏
D
后退
顶部