创建或修改视图:
下方这些为转载信息:
1、ALTER viewtest1 as
create(alter) view abc as
select
l.id as lId,
cast(l.password as int) as password, 字符串 ---> int
cast(l.age as int) as ageInt, 字符串 ---> int
convert(nvarchar(255),p.id) as idString, int ---> 字符串
convert(nvarchar(255),p.weight) as weightString, int ---> 字符串
convert (nvarchar(255) , p.price) as priceString int ---> 字符串
from dbo.login as l , dbo.product as p
;
重点关注cast 和 convert 关键字的用法。
sp_help 视图名字;查询视图详细内容
下方这些为转载信息:
1、ALTER viewtest1 as
select NAME ASNAMEINT,AGE AS AGEINT FROM TEST (name保持表中类型)
2、sp_help test1
NAMEINT
varchar no 50 yes no yesChinese_PRC_CI_AS
AGEINT int no 4 10 0 yes (n/a) (n/a) NULL
1、ALTER view test1
as
select
CAST(NAME AS INT) AS NAMEINT,AGE AS AGEINT FROMTEST (将varchar类型改为int类型)
2、sp_help test1
NAMEINT
int no 4 10 0 yes (n/a) (n/a) NULL
AGEINT int no 4 10 0 yes (n/a) (n/a) NULL
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------