ljhodgett
asked on
SQL syntax error
Hi,
I am trying to join 2 columns togather to make one. I have been given the sql statement: -
SET NOCOUNT ON; SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, PartIdentity SSDNumber + Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
but it comes up Incorrect syntax near '+'. What am I doing wrong please.
Many Thanks
Lee
I am trying to join 2 columns togather to make one. I have been given the sql statement: -
SET NOCOUNT ON; SELECT TestRigID,SSDNumber, Description,CalibrationDue
but it comes up Incorrect syntax near '+'. What am I doing wrong please.
Many Thanks
Lee
ASKER
Hi,
it comes up Invalid column name 'PartIdentity SSDNumber'. The two columns are SSDNumber and Description that I am trying to join together. I take it partIdentify is a function of sql is it?
Many Thanks
Lee
it comes up Invalid column name 'PartIdentity SSDNumber'. The two columns are SSDNumber and Description that I am trying to join together. I take it partIdentify is a function of sql is it?
Many Thanks
Lee
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, PartIdentity SSDNumber + Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
Here is the problem PartIdentity SSDNumber
If these are column then place comma in between them or use + sign if you want concatenate...
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, PartIdentity, SSDNumber + Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
or
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, Cast(PartIdentity as varchar) + cast(SSDNumber as varchar) + Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
SELECT TestRigID,SSDNumber, Description,CalibrationDue
Here is the problem PartIdentity SSDNumber
If these are column then place comma in between them or use + sign if you want concatenate...
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue
or
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue
No PartIdentity is not a function....
ASKER
Hi,
Right, for some reason I was given partidentify for this. I haven't even got a column called part identify so I would forget about this. I have tried: -
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, SSDNumber + Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
but it comes up : -
Msg 8114, Level 16, State 5, Line 2
Error converting data type varchar to numeric.
Best Regards
Lee
Right, for some reason I was given partidentify for this. I haven't even got a column called part identify so I would forget about this. I have tried: -
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue
but it comes up : -
Msg 8114, Level 16, State 5, Line 2
Error converting data type varchar to numeric.
Best Regards
Lee
If SSDNumber is numeric, you should use this:
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, CAST(SSDNumber AS VARCHAR)+ Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue
ASKER
Hi,
I've managed to join them now using: -
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue ,bUserLock ,DocNum,Jo bReference ,RoutingSt age,bPCBTe ster,bDriv eTester, bObsolete, cast(SSDNumber as varchar) + Description as SSDNumber_Description FROM Admin_SSDNumber WHERE bLogicalDelete=0 ORDER BY SSDNumber;
but I need it to put a space in between SSDNumber and Description as it places both together.
Many Thanks
Lee
I've managed to join them now using: -
SET NOCOUNT ON;
SELECT TestRigID,SSDNumber, Description,CalibrationDue
but I need it to put a space in between SSDNumber and Description as it places both together.
Many Thanks
Lee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
That works great thank you. I've posted a follow on question as it was sort of a new question but follows this one.
Best Regards
Lee
That works great thank you. I've posted a follow on question as it was sort of a new question but follows this one.
Best Regards
Lee
SET NOCOUNT ON; SELECT TestRigID,SSDNumber, Description,CalibrationDue