将nvarchar转换为int时出错 [英] Error converting nvarchar to int
本文介绍了将nvarchar转换为int时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到此错误。有人可以帮我这个
消息245,等级16,状态1,行3
转换nvarchar值时转换失败' 'account 1''到数据类型int。
SELECT New_accountid AS AccountId
FROM BingMapsPlatform_MSCRM.dbo.FilteredAccount WITH ( NOLOCK )
WHERE new_islicensed = ' 1'
AND new_accountid 不 IN ( SELECT DISTINCT New_AccountId
FROM BingMapsPlatform_MSCRM.dbo.New_keydenylistExtensionBase W ITH ( NOLOCK )
WHERE New_AccountId IS NOT NULL )
SELECT New_accountid AS AccountId
FROM BingMapsPlatform_MSCRM.dbo.FilteredAccount WITH ( NOLOCK )
WHERE new_islicensed = ' 1'
AND CONVERT ( NVARCHAR ( 100 ),New_AccountId)< span class =code-keyword> NOT IN ( SELECT DISTINCT CONVERT ( NVARCHAR ( 100 ),New_AccountId) AS New_AccountId
< span class =code-keyword> FROM BingMapsPlatform_MSCRM.dbo.New_keydenylistExtensionBase WITH ( NOLOCK )
WHERE New_AccountId IS NOT NULL )
查看以下链接...
我们会清楚了解数据类型转换。
数据类型转换(数据库引擎) [ ^ ]
SQL Server中的数据转换 [ ^ ]
显式转换SQL Server数据类型的10个理由 [ ^ ]
问候,
GVPrabu
I am getting this error. Can somebody please help me in this
Msg 245, Level 16, State 1, Line 3
Conversion failed when converting the nvarchar value ''account 1'' to data type int.
SELECT New_accountid AS AccountId
FROM BingMapsPlatform_MSCRM.dbo.FilteredAccount WITH (NOLOCK)
WHERE new_islicensed = '1'
AND new_accountid NOT IN (SELECT DISTINCT New_AccountId
FROM BingMapsPlatform_MSCRM.dbo.New_keydenylistExtensionBase WITH (NOLOCK)
WHERE New_AccountId IS NOT NULL)
解决方案
Try this:
SELECT New_accountid AS AccountId FROM BingMapsPlatform_MSCRM.dbo.FilteredAccount WITH (NOLOCK) WHERE new_islicensed = '1' AND CONVERT(NVARCHAR(100),New_AccountId) NOT IN (SELECT DISTINCT CONVERT(NVARCHAR(100),New_AccountId) AS New_AccountId FROM BingMapsPlatform_MSCRM.dbo.New_keydenylistExtensionBase WITH (NOLOCK) WHERE New_AccountId IS NOT NULL)
Hi,
Check the following link...
U ll get clear idea about data type conversion.
Data Type Conversion (Database Engine)[^]
Data Conversion in SQL Server[^]
10 reasons to explicitly convert SQL Server data types[^]
Regards,
GVPrabu
这篇关于将nvarchar转换为int时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文