SQLserver查詢語句重新命名時,列名的別名無效

2021-10-09 09:14:59 字數 715 閱讀 3282

原來的語句:

select distinct wtdh,dwmc,gcmc,zh,sgbw,memo,syxm,qyr,qyrzs,jzdw,jzr,jzrzs,sysl as sybh,wtdw,gcmc,sgbw,tyzl,sjyq,jccs,qyr,qyrzsh,jzdw,jzr,jzrzsh,sysl from htmis.dbo.gl_xcsywtd where wtdh=

'tg0500001s'

;

修改為:

select xc.wtdh sybh,xc.dwmc wtdw,xc.gcmc,xc.zh sgbw,xc.sgbw tyzl,xc.memo sjyq,xc.syxm jccs,xc.qyr,xc.qyrzs qyrzsh,xc.jzdw,xc.jzr,xc.jzrzs jzrzsh,xc.sysl from gl_xcsywtd xc where xc.wtdh=

'tg0500001s'

;

至於為啥。。就很迷啊。。。

另外如果是要省略表名前面的htmis.dbo的話,需要在左上方修改為htmis

SQL Server 分頁查詢語句

create database xuhanglove gouse xuhanglove gocreate table product pid int primary key identity 1,1 pname varchar 255 not null unique,price float pdat...

sql server分頁查詢語句

sqlserver分頁查詢 查詢10條第一頁資料 10代表一頁多少條 頁數為10 1 1 select top 10 from dbo userinfo where ui fvaruserid not in select top 0 ui fvaruserid from dbo userinfo o...

SQLServer2008語句查詢

1 判斷資料庫是否存在 if exists select from sys.databases where name 資料庫名 drop database 資料庫名 2 判斷表是否存在 if exists select from sysobjects where id object id 表名 an...