SQL的字符转换问题
CREATE VIEW t
AS
SELECT
a.a + a.b + a.c as tt from ttt as a
如果表ttt中的a,b,c为字符类型时就可以
现在出现的问题是a,b,c类型不同
应该如何处理?
[解决办法]
CREATE VIEW t
AS
SELECT
cast(a.a as varchar(10)) + cast(a.b as varchar(10)) + cast(a.c as varchar(10)) as tt from ttt as a
[解决办法]
--刚刚看错了,用ls的吧,不过要改改,转换成varchar时最好不要加长度,不然长度超出了,就会截断了。
CREATE VIEW t
AS
SELECT
cast(a.a as varchar) + cast(a.b as varchar) + cast(a.c as varchar) as tt from ttt as a