Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conversion failed when converting the nvarchar value 'China Exclusive Products - purchases inc Paper Bags' to data type int.

Posted on 2011-09-02
2
Medium Priority
?
353 Views
Last Modified: 2012-05-12
Umm SQL conversion query...

My Select statement is -

SELECT 
ID,  
Code +  [General-Ledger-Account] 
AS NominalCode 
FROM dbo.[Nominal-Codes] 
Order by Code

Open in new window


ID is an Int
Code is an INT
[General-Ledger-Account]  is nvarchar(100)

Please advise work around..

Thank you
0
Comment
Question by:garethtnash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
Christopher Gordon earned 2000 total points
ID: 36473205
You should CAST the Code field.  Something like this:

SELECT
ID,  
cast(Code as nvarchar(50)) +  [General-Ledger-Account]
AS NominalCode
FROM dbo.[Nominal-Codes]
Order by Code
0
 

Author Closing Comment

by:garethtnash
ID: 36473245
thank you
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question