Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.

SQL
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)
Posted
Comments
Richard MacCutchan 19-Mar-13 5:59am    
That seems quite clear, "account 1" is not an integer.
[no name] 19-Mar-13 6:43am    
There might be "new_accountid" from one BingMapsPlatform_MSCRM.dbo.FilteredAccount is having different data data type than "New_AccountId" in BingMapsPlatform_MSCRM.dbo.New_keydenylistExtensionBase.
ZurdoDev 19-Mar-13 7:16am    
Likely New_AccountId in New_keydenylistExtensionBase is an int but in FilteredAccount it is nvarchar. However, it's your data so you'll have to figure out why.

Try this:

SQL
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)
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900