Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread A Little Help Please
Wed, Mar 26 2014 12:34 PMPermanent Link

Kralic

Avatar

I'm trying to run a SQL statement that inserts into one table from another but everytime i go to prepare the SQL it is returning an error. (See attachment)
Below is a copy of the SQL I'm using, I have a feeling this is something really obvious but i just cant see it.... If anyone could advise that would be great. Could this be done to different data types in the columns in the 'stock' table compared to the 'JD_Imports' table and if so, what is the easiest way to rectify this without changing the data types in either table?

SQL Code;

INSERT INTO Stock
(
PartSupID,   
WarehouseCode,   
StkCode,   
StkDescription,   
StkCostValue,   
StkCostCurrencyValue,   
StkCostDate,   
StkQuantInStock,   
StkReorderLevel,   
StkOnOrder,   
StkToOrder,   
StkSupplierID,   
StkCategory,   
StkType,   
StkLocation,   
StkSalePrice,   
StkSaleDate,   
StkCostCurrency,   
StkMin,   
StkMax,   
StkContractPrice,   
StkLastUsed,   
StkTotalUsed,   
StkTotalStocked,   
StkSerialised,   
StkAlert,   
StkETA,   
StkSuppTheoretical,   
StkSuppAvailable,   
StkSuppUpdated,   
StkMyStock,   
StkNominal,   
StkMultipleLoc,   
StkNoneStock,   
StkSupAccountID,   
StkSupStockCode,   
StkTaxCode,   
StkNominalPOR,   
StkWeight,   
StkAvgDeliveryDays,   
StkNominalCostSales,   
StkNominalProfit,   
StkNominalBalance,   
StkNominalWIP,   
StkDirectSale,   
StkBarCode,   
StkManufacturerCode,   
StkManufacturerMatched,   
StkManufacturerUnique,   
StkGenuinePart,   
StkBrand,   
StkWebDescription   
)

SELECT
   
PartSupID,
WarehouseCode,
StkCode,
StkDescription,   
StkCostValue,   
StkCostCurrencyValue,   
StkCostDate,   
StkQuantInStock,   
StkReorderLevel,   
StkOnOrder,   
StkToOrder,   
StkSupplierID,   
StkCategory,   
StkType,   
StkLocation,   
StkSalePrice,   
StkSaleDate,   
StkCostCurrency,   
StkMin,   
StkMax,   
StkContractPrice,   
StkLastUsed,   
StkTotalUsed,   
StkTotalStocked,   
StkSerialised,   
StkAlert,   
StkETA,   
StkSuppTheoretical,   
StkSuppAvailable,   
StkSuppUpdated,   
StkMyStock,   
StkNominal,   
StkMultipleLoc,   
StkNoneStock,   
StkSupAccountID,   
StkSupStockCode,   
StkTaxCode,   
StkNominalPOR,   
StkWeight,   
StkAvgDeliveryDays,   
StkNominalCostSales,   
StkNominalProfit,   
StkNominalBalance,   
StkNominalWIP,   
StkDirectSale,   
StkBarCode,   
StkManufacturerCode,   
StkManufacturerMatched,   
StkManufacturerUnique,   
StkGenuinePart,   
StkBrand,   
StkWebDescription
   
FROM
JD_Imports
Wed, Mar 26 2014 1:15 PMPermanent Link

Raul

Team Elevate Team Elevate

On 3/26/2014 12:34 PM, Kralic wrote:
> I'm trying to run a SQL statement that inserts into one table from another but everytime i go to prepare the SQL it is returning an error. (See attachment)
> Below is a copy of the SQL I'm using, I have a feeling this is something really obvious but i just cant see it.... If anyone could advise that would be great. Could this be done to different data types in the columns in the 'stock' table compared to the 'JD_Imports' table and if so, what is the easiest way to rectify this without changing the data types in either table?
>
Telling us what the error is would help. SQL looks ok to me.

However is you have data type differences then that would likely be a
problem - see CAST function in the SQL reference if you need to do
conversions:

http://www.elevatesoft.com/manual?action=viewtopic&id=dbisam4&product=rsdelphiwin32&version=XE5&topic=Functions

Raul
Thu, Mar 27 2014 6:33 AMPermanent Link

Kralic

Avatar

Raul wrote:

On 3/26/2014 12:34 PM, Kralic wrote:
> I'm trying to run a SQL statement that inserts into one table from another but everytime i go to prepare the SQL it is returning an error. (See attachment)
> Below is a copy of the SQL I'm using, I have a feeling this is something really obvious but i just cant see it.... If anyone could advise that would be great. Could this be done to different data types in the columns in the 'stock' table compared to the 'JD_Imports' table and if so, what is the easiest way to rectify this without changing the data types in either table?
>
Telling us what the error is would help. SQL looks ok to me.

However is you have data type differences then that would likely be a
problem - see CAST function in the SQL reference if you need to do
conversions:

http://www.elevatesoft.com/manual?action=viewtopic&id=dbisam4&product=rsdelphiwin32&version=XE5&topic=Functions

Raul

Upon investigating this a little more I've realised it is down to differences in the data types in the two tables. Thankfully, using the CAST function I was able to do this import. But thank you for your response.
Image