October 30, 2018 at 10:26 am
Hello ,
Can someone point me in the right direction here. I'm having a hard time figuring this out.
I have a field - [cust_po] [varchar](20) NULL, and get a Msg 207 Invalid column name. when trying to insert. I'm using an "insert into" select , the source field is an alpha numeric and has values such as this ... SSS-BLAN-2014
I tried changing the target field data type to all kinds including float etc. but no luck.
hopefully its something simple
Thanks
Greg J
October 30, 2018 at 11:42 am
Can you give us an example of an entire query which fails - something which we can run in isolation?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
October 30, 2018 at 11:50 am
The error message is clear: "Invalid column name...." The error message also tells you which column name is invalid, but you didn't include that part in your post. You need to fix the name (not the data type) of the invalid column.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 30, 2018 at 12:56 pm
Phil Parkin - Tuesday, October 30, 2018 11:42 AMCan you give us an example of an entire query which fails - something which we can run in isolation?
USE [SSSUTIL]
GO
October 30, 2018 at 12:58 pm
drew.allen - Tuesday, October 30, 2018 11:50 AMThe error message is clear: "Invalid column name...." The error message also tells you which column name is invalid, but you didn't include that part in your post. You need to fix the name (not the data type) of the invalid column.Drew
Drew, thanks but I'm not sure I see what the problem with the name is ? I'm using a [Cust_po] I'm using other columns with an underscore as well and they are not a problem ?
hankst
October 30, 2018 at 1:27 pm
Looks to me that cust_po may not be the column name in the table. Of course we don't know that as we can't see what you can see.
October 30, 2018 at 1:30 pm
gjoelson 29755 - Tuesday, October 30, 2018 12:56 PMPhil Parkin - Tuesday, October 30, 2018 11:42 AMCan you give us an example of an entire query which fails - something which we can run in isolation?Here is a sample of what I was trying to do , this is a simple insert , but my actual task is an "insert into select" . but I broke it out like this so I could try understand what was happening.
This column issue is ,[cust_po] to get it to work I have to add single quotes ' 'USE [SSSUTIL]
GOINSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
VALUES
(38322
,B123
,2)
GO
B123 is a string and therefore needs to be 'B123'
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
October 30, 2018 at 2:13 pm
Lynn Pettis - Tuesday, October 30, 2018 1:27 PMLooks to me that cust_po may not be the column name in the table. Of course we don't know that as we can't see what you can see.
Lynn,
so the [cust_po] is in the destination table below is a sample of some of the columns and specifically the Cust_po column. also I have screenshot the query and attached the files.
CREATE TABLE [dbo].[CustomerOrders](
[ID] [int] IDENTITY(1,1) NOT NULL,
[co_num] [varchar](20) NULL,
[cust_po] [varchar](20) NULL,
[co_line] [int] NULL,
[co_release] [int] NULL,
[item] [char](25) NULL, ........
Thanks
October 30, 2018 at 2:16 pm
Phil Parkin - Tuesday, October 30, 2018 1:30 PMgjoelson 29755 - Tuesday, October 30, 2018 12:56 PMPhil Parkin - Tuesday, October 30, 2018 11:42 AMCan you give us an example of an entire query which fails - something which we can run in isolation?Here is a sample of what I was trying to do , this is a simple insert , but my actual task is an "insert into select" . but I broke it out like this so I could try understand what was happening.
This column issue is ,[cust_po] to get it to work I have to add single quotes ' 'USE [SSSUTIL]
GOINSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
VALUES
(38322
,B123
,2)
GOB123 is a string and therefore needs to be 'B123'
Yes, correct when I add the quotes it inserts. But since I'm doing a "Insert into Select" I cant do that. any suggestions ?
Thanks
October 30, 2018 at 2:28 pm
gjoelson 29755 - Tuesday, October 30, 2018 2:16 PMPhil Parkin - Tuesday, October 30, 2018 1:30 PMgjoelson 29755 - Tuesday, October 30, 2018 12:56 PMPhil Parkin - Tuesday, October 30, 2018 11:42 AMCan you give us an example of an entire query which fails - something which we can run in isolation?Here is a sample of what I was trying to do , this is a simple insert , but my actual task is an "insert into select" . but I broke it out like this so I could try understand what was happening.
This column issue is ,[cust_po] to get it to work I have to add single quotes ' 'USE [SSSUTIL]
GOINSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
VALUES
(38322
,B123
,2)
GOB123 is a string and therefore needs to be 'B123'
Yes, correct when I add the quotes it inserts. But since I'm doing a "Insert into Select" I cant do that. any suggestions ?
Thanks
A what?
October 30, 2018 at 2:32 pm
gjoelson 29755 - Tuesday, October 30, 2018 2:16 PMPhil Parkin - Tuesday, October 30, 2018 1:30 PMgjoelson 29755 - Tuesday, October 30, 2018 12:56 PMPhil Parkin - Tuesday, October 30, 2018 11:42 AMCan you give us an example of an entire query which fails - something which we can run in isolation?Here is a sample of what I was trying to do , this is a simple insert , but my actual task is an "insert into select" . but I broke it out like this so I could try understand what was happening.
This column issue is ,[cust_po] to get it to work I have to add single quotes ' 'USE [SSSUTIL]
GOINSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
VALUES
(38322
,B123
,2)
GOB123 is a string and therefore needs to be 'B123'
Yes, correct when I add the quotes it inserts. But since I'm doing a "Insert into Select" I cant do that. any suggestions ?
Thanks
What is the datatype of the source column and what is the datatype of the target column?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
October 30, 2018 at 2:47 pm
gjoelson 29755 - Tuesday, October 30, 2018 2:13 PMLynn Pettis - Tuesday, October 30, 2018 1:27 PMLooks to me that cust_po may not be the column name in the table. Of course we don't know that as we can't see what you can see.Lynn,
so the [cust_po] is in the destination table below is a sample of some of the columns and specifically the Cust_po column. also I have screenshot the query and attached the files.CREATE TABLE [dbo].[CustomerOrders](
[ID] [int] IDENTITY(1,1) NOT NULL,
[co_num] [varchar](20) NULL,
[cust_po] [varchar](20) NULL,
[co_line] [int] NULL,
[co_release] [int] NULL,
[item] [char](25) NULL, ........Thanks
You reference TWO fields name cust_po: one in the target table (which you've checked) and one in EES_App.dbo.co (which you haven't checked). I'm guessing that it's not a valid column in the second table.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 30, 2018 at 3:14 pm
Phil Parkin - Tuesday, October 30, 2018 2:32 PMgjoelson 29755 - Tuesday, October 30, 2018 2:16 PMPhil Parkin - Tuesday, October 30, 2018 1:30 PMgjoelson 29755 - Tuesday, October 30, 2018 12:56 PMPhil Parkin - Tuesday, October 30, 2018 11:42 AMCan you give us an example of an entire query which fails - something which we can run in isolation?Here is a sample of what I was trying to do , this is a simple insert , but my actual task is an "insert into select" . but I broke it out like this so I could try understand what was happening.
This column issue is ,[cust_po] to get it to work I have to add single quotes ' 'USE [SSSUTIL]
GOINSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
VALUES
(38322
,B123
,2)
GOB123 is a string and therefore needs to be 'B123'
Yes, correct when I add the quotes it inserts. But since I'm doing a "Insert into Select" I cant do that. any suggestions ?
Thanks
What is the datatype of the source column and what is the datatype of the target column?
Source column is nvarchar and target column is Varchar (20)
did try the target with various other type including nvarchar.
October 30, 2018 at 3:19 pm
drew.allen - Tuesday, October 30, 2018 2:47 PMgjoelson 29755 - Tuesday, October 30, 2018 2:13 PMLynn Pettis - Tuesday, October 30, 2018 1:27 PMLooks to me that cust_po may not be the column name in the table. Of course we don't know that as we can't see what you can see.Lynn,
so the [cust_po] is in the destination table below is a sample of some of the columns and specifically the Cust_po column. also I have screenshot the query and attached the files.CREATE TABLE [dbo].[CustomerOrders](
[ID] [int] IDENTITY(1,1) NOT NULL,
[co_num] [varchar](20) NULL,
[cust_po] [varchar](20) NULL,
[co_line] [int] NULL,
[co_release] [int] NULL,
[item] [char](25) NULL, ........Thanks
You reference TWO fields name cust_po: one in the target table (which you've checked) and one in EES_App.dbo.co (which you haven't checked). I'm guessing that it's not a valid column in the second table.
Drew
Drew, yup it is valid in the source table , I'm using some joins and it exists in the [CO] on the join
October 30, 2018 at 3:22 pm
gjoelson 29755 - Tuesday, October 30, 2018 3:19 PMdrew.allen - Tuesday, October 30, 2018 2:47 PMgjoelson 29755 - Tuesday, October 30, 2018 2:13 PMLynn Pettis - Tuesday, October 30, 2018 1:27 PMLooks to me that cust_po may not be the column name in the table. Of course we don't know that as we can't see what you can see.Lynn,
so the [cust_po] is in the destination table below is a sample of some of the columns and specifically the Cust_po column. also I have screenshot the query and attached the files.CREATE TABLE [dbo].[CustomerOrders](
[ID] [int] IDENTITY(1,1) NOT NULL,
[co_num] [varchar](20) NULL,
[cust_po] [varchar](20) NULL,
[co_line] [int] NULL,
[co_release] [int] NULL,
[item] [char](25) NULL, ........Thanks
You reference TWO fields name cust_po: one in the target table (which you've checked) and one in EES_App.dbo.co (which you haven't checked). I'm guessing that it's not a valid column in the second table.
Drew
Drew, yup it is valid in the source table , I'm using some joins and it exists in the [CO] on the join
- FROM [EES_app].[dbo].[coitem] a
left join [EES_App].[dbo].[co] B on a.co_num =b.co_num
I meant to add that , that its a column on table B , so yes its on both the source and target tables) I'm wondering if the join has something to do with it ?
Viewing 15 posts - 1 through 15 (of 33 total)
You must be logged in to reply to this topic. Login to reply