34,594
社区成员
发帖
与我相关
我的任务
分享
Select a.ID,b.ID From Table1 as a inner join Table2 as b on a.ID = b.ID
但是提示类型转化错误:Error converting data type nvarchar to bigint.
]
'借用楼上'
declare @t1 table(id bigint)
declare @t2 table(id nvarchar(10))
insert @t1 select 2
insert @t2 select '2'
select *
from @t1 a,@t2 b
where a.id = cast(b.id as bigint)
select *
from @t1 a,@t2 b
where cast(a.id as nvarchar) = b.id
select * from Table1 inner join Table2 on Table1.id = Table2.id
where isnumeric(Table1.id) = 1
declare @t1 table(id bigint)
declare @t2 table(id nvarchar(10))
insert @t1 select 2
insert @t2 select '2'
select *
from @t1 a,@t2 b
where a.id = cast(b.id as bigint)
select *
from @t1 a,@t2 b
where cast(a.id as nvarchar) = b.id
/*
id id
-------------------- ----------
2 2
id id
-------------------- ----------
2 2
*/
Select a.ID,b.ID From Table1 as a inner join Table2 as b on cast(a.ID as varchar) = cast(b.ID as varchar)