這次接手人家的網站
雖然人家也是先包給某家廠商後來才找我們把後面功能弄好一"一
由於人家弄得資料表有問題
例如年的欄位用varchar..........月的欄位.....數量的欄位通通都用varchar........
暈倒XD
這樣我們怎麼做查詢XD
起初我的想法是改table
可惜不給改..........沒辦法就是降子
好在張睪提供了好方法.....
用View
就是新增一個View把該table查詢出來的欄位都轉型
這樣就大功告成.......真的是方法中的方法0rz.......
此為我們新增的view~~~欄位超多所以超長XD
SELECT SN, CONVERT(datetime, Year + '-' + Month + '-01') AS date, CAST(GG1 AS int) AS GG1, CAST(GG2 AS int)
AS GG2, CAST(GG3 AS int) AS GG3, CAST(GG4 AS int) AS GG4, CAST(GG5 AS int) AS GG5,
CAST(GG6 AS int) AS GG6, CAST(GG7 AS int) AS GG7, CAST(GG8 AS int) AS GG8, CAST(GG9 AS int)
AS GG9, CAST(GG10 AS int) AS GG10, CAST(GG11 AS int) AS GG11, CAST(GG12 AS int) AS GG12,
CAST(GG13 AS int) AS GG13, CAST(GG14 AS int) AS GG14, CAST(GG15 AS int) AS GG15,
CAST(GG16 AS int) AS GG16, CAST(GG17 AS int) AS GG17, CAST(GG18 AS int) AS GG18,
CAST(GG19 AS int) AS GG19, CAST(GG20 AS int) AS GG20, CAST(GG21 AS int) AS GG21,
CAST(GG22 AS int) AS GG22, CAST(GG23 AS int) AS GG23, CAST(GG24 AS int) AS GG24,
CAST(GG25 AS int) AS GG25, CAST(GG26 AS int) AS GG26, CAST(GG27 AS int) AS GG27,
CAST(GG28 AS int) AS GG28, CAST(GG29 AS int) AS GG29, CAST(GG30 AS int) AS GG30,
CAST(GG31 AS int) AS GG31, CAST(GG32 AS int) AS GG32, CAST(GG33 AS int) AS GG33,
CAST(GG34 AS int) AS GG34, CAST(GG35 AS int) AS GG35, CAST(GG36 AS int) AS GG36,
CAST(GG37 AS int) AS GG37, CAST(GG38 AS int) AS GG38, CAST(GG39 AS int) AS GG39,
CAST(GG40 AS int) AS GG40, CAST(GG41 AS int) AS GG41, CAST(GG42 AS int) AS GG42,
CAST(GG43 AS int) AS GG43, CAST(GG44 AS int) AS GG44, CAST(GG45 AS int) AS GG45,
CAST(GG46 AS int) AS GG46
FROM dbo.Quality
Không có nhận xét nào:
Đăng nhận xét