sql问题
select name from syscolumns where id = object_id('海塘里程碑情况表')
这句Sql语句获取海塘里程碑情况表的列名
select a.*,b.海塘名称 from 海塘里程碑情况表 a(nolock) left join 海塘属性表 b(nolock) on a.海塘ID = b.海塘ID
如何获取上表的列名
sp_columns '表名'
SQL code:
select name from syscolumns where id = object_id('海塘里程碑情况表') union all
select name from syscolumns where id = object_id('海塘属性表')
哦。把
select a.*,b.海塘名称 from 海塘里程碑情况表 a(nolock) left join 海塘属性表 b(nolock) on a.海塘ID = b.海塘ID
变成一个视图
create view 视图名称
as
select a.*,b.海塘名称 from 海塘里程碑情况表 a(nolock) left join 海塘属性表 b(nolock) on a.海塘ID = b.海塘ID
然后
select name from syscolumns where id = object_id('视图名称')
SQL code:
select 海塘名称字段,海塘属性表.* from 海塘里程碑情况表,海塘属性表 where 海塘里程碑情况表.id=海塘属性表.id and 海塘名称="要查询海塘名称"
说明,查询海塘里程碑情况表里与海塘属性表里面id相同,并且海塘名称为"要查询海塘名称"的所有记录,如果两个表里面有相同字段,则要说明是哪个表里面的字段!
海塘里程碑情况表里面的id对应海塘属性表里面的i
相关问答:
表如下
教室ID 座位数 开始时间 结束时间 2009年1月1日 2009年1月2日 2009年1月3日
101 50 08:00 08:30 30 40 50
101 50 09:00 ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
--drop table #T1
--drop table #T2
create Table #T1(ID int,
QueryID nvarchar(20),
ResultID1 nvarchar(20),
ResultID2 nvarchar(20))
create Table #T2(SortNo int,
QueryID nvarchar(20),
ResultID1 nv ......
clientserial devseral chunnelnum devdata5
CZ0001 308001 5000 11.1
CZ0001 308001 5001 11.2
CZ0001 308001 5002 11.3
CZ0001 3080 ......