473,543 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

invalid column name

24 New Member
This code works fine in access but i'm moving this query to sql it compiles fine but then when i try to execute it i get numerous errors of invalid columns. I've attached a sample of the code. As always your help is greatly appreciated.


Before this is the code from a access 2007 query
Expand|Select|Wrap|Line Numbers
  1. SELECT tships.[Load ],
  2.        tships.[Ship Id],
  3. Trim([XPD flag] & " " & [ACDT flag] & " " & [AFP flag] & " " & [AHTL flag] & " " & [AOC FLAG] & " " & [BUMP FLAG] & " " & [CARQ FLAG] & " " & [CDEL FLAG] & " " & [CFAL FLAG] & " " & [CNSW FLAG] & " " & [CRIT FLAG] & " " & [CROL FLAG] & " " & [CRTR FLAG] & " " & [CRVT FLAG] & " " & [CUDC FLAG] & " " & [DATA FLAG] & " " & [DATE FLAG] & " " & [DEFL FLAG] & " " & [DETN FLAG] & " " & [DIC FLAG] & " " & [DLDM FLAG] & " " & [DLSH FLAG] & " " & [DMRC FLAG] & " " & [DROP FLAG] & " " & [DRSK FLAG] & " " & [DTNA FLAG] & " " & [FTZ FLAG] & " " & [ILOD FLAG] & " " & [INFO FLAG] & " " & [LCFP FLAG] & " " & [LFCG FLAG] & " " & [LNFT FLAG] & " " & [MDWD FLAG] & " " & [MNMC FLAG] & " " & [MNSL FLAG] & " " & [MSCU FLAG] & " " & [NOLT FLAG] & " " & [ODEL FLAG] & " " & [OTHR FLAG])                        AS [Reason Codes1],
  4. Trim([PRLD FLAG] & " " & [QUOT FLAG] & " " & [RAIL FLAG] & " " & [RCAA FLAG] & " " & [RCC FLAG] & " " & [RCEG FLAG] & " " & [RCIN FLAG] & " " & [RCL FLAG] & " " & [RCLN FLAG] & " " & [RCLP FLAG] & " " & [RCMC FLAG] & " " & [RCNP FLAG] & " " & [RCPS FLAG] & " " & [RCQU FLAG] & " " & [RCSC FLAG] & " " & [RCSE FLAG] & " " & [RCSH FLAG] & " " & [RCSP FLAG] & " " & [RCSQ FLAG] & " " & [RCSU FLAG] & " " & [RCTT FLAG] & " " & [RCTW FLAG] & " " & [RCWA FLAG] & " " & [RUSH FLAG] & " " & [RUTM FLAG] & " " & [SCBK FLAG] & " " & [SDEL FLAG] & " " & [SHTG FLAG] & " " & [SHTT FLAG] & " " & [SPEQ FLAG] & " " & [STDL FLAG] & " " & [TDDE FLAG] & " " & [TEAM FLAG] & " " & [TLCO FLAG] & " " & [UPSD FLAG] & " " & [VORL FLAG] & " " & [WTHR FLAG] & " " & [XRTE FLAG] & " " & [CCBK FLAG] & " " & [WBDN FLAG]) AS [Reason Codes2],
  5. AS [Reason Codes3],
  6. AS [XPD flag],
  7.  



After this it the modifications that i've made
Expand|Select|Wrap|Line Numbers
  1. SELECT tShips.[Load ],
  2.        tShips.[Ship Id],
  3.     LTrim([XPD flag] + [ACDT flag] + [AFP flag] + [AHTL flag] + [AOC FLAG] + [BUMP FLAG] + [CARQ FLAG] + [CDEL FLAG] + [CFAL FLAG] + [CNSW FLAG] + [CRIT FLAG] + [CROL FLAG] + [CRTR FLAG] + [CRVT FLAG] + [CUDC FLAG] + [DATA FLAG] + [DATE FLAG] + [DEFL FLAG] + [DETN FLAG] + [DIC FLAG] + [DLDM FLAG] + [DLSH FLAG] + [DMRC FLAG] + [DROP FLAG] + [DRSK FLAG] + [DTNA FLAG] + [FTZ FLAG] + [ILOD FLAG] + [INFO FLAG] + [LCFP FLAG] + [LFCG FLAG] + [LNFT FLAG] + [MDWD FLAG] + [MNMC FLAG] + [MNSL FLAG] + [MSCU FLAG] + [NOLT FLAG] + [ODEL FLAG] + [OTHR FLAG]) AS [Reason Codes1],
  4.     LTrim([PRLD FLAG] + [QUOT FLAG] + [RAIL FLAG] + [RCAA FLAG] + [RCC FLAG] + [RCEG FLAG] + [RCIN FLAG] + [RCL FLAG] + [RCLN FLAG] + [RCLP FLAG] + [RCMC FLAG] + [RCNP FLAG] + [RCPS FLAG] + [RCQU FLAG] + [RCSC FLAG] + [RCSE FLAG] + [RCSH FLAG] + [RCSP FLAG] + [RCSQ FLAG] + [RCSU FLAG] + [RCTT FLAG] + [RCTW FLAG] + [RCWA FLAG] + [RUSH FLAG] + [RUTM FLAG] + [SCBK FLAG] + [SDEL FLAG] + [SHTG FLAG] + [SHTT FLAG] + [SPEQ FLAG] + [STDL FLAG] + [TDDE FLAG] + [TEAM FLAG] + [TLCO FLAG] + [UPSD FLAG] + [VORL FLAG] + [WTHR FLAG] + [XRTE FLAG] + [CCBK FLAG] + [WBDN FLAG]) AS [Reason Codes2],
  5.     LTrim([reason codes1] & [reason codes2]) AS [Reason Codes3],
  6.        CASE 
  7.          WHEN [xpd] = 1
  8.          THEN 'XPD'
  9.          ELSE NULL
  10.        END AS [XPD FLAG],
  11.  
Mar 11 '10 #1
3 1827
ck9663
2,878 Recognized Expert Specialist
What column is throwing the error? And you also missed on in

Expand|Select|Wrap|Line Numbers
  1.  
  2. LTrim([reason codes1] & [reason codes2]) AS [Reason Codes3]
  3.  
  4.  
Happy Coding!!!

~~ CK
Mar 12 '10 #2
Anthony97
24 New Member
I changed the & to + between [reason codes1] + [reason codes2] I'm still getting invalid columns starting with xpd flag and it continues to the next flag
Mar 12 '10 #3
ck9663
2,878 Recognized Expert Specialist
Check if all these columns are in your table. Also, there's no TRIM() function in SQL Server. Only LTRIM() and RTRIM().

Good Luck!!!

~~ CK
Mar 12 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6309
by: | last post by:
When I execute the following (with an OleDBDataAdapter), wanting to add a row to a visual foxpro table: myrow= datasetTarget.Tables(0).NewRow 'fill all columns here like.. row(i)= myvalue ' then datasetTarget.Tables(0).Rows.Add(myrow) dataAdapterTarget.Update(datasetTarget.Tables(0)) '*
1
3234
by: chelleybabyger | last post by:
Using the below method, <% remaining_stock = cint(product_stock) - cint(chQuantity) %> <% sqlString = "UPDATE Products SET " &_ "product_stock='" & remaining_stock & "'," &_ "WHERE product_id='" &chID& "'"
8
64800
by: Shino | last post by:
Hi, Can anyone help with this error: "ORA-00904: invalid column name"? Thanks! SQL> create view PPFa as 2 SELECT L.UserID AS LecID, U.Name, U.Email, I.IntakeID, S.UserID AS StudID 3 FROM User_Lecturer L, User_Student S, TBL_Intake I, Users U 4 WHERE L.UserID=S.InitialSupervisorID And L.UserID=U.UserID And
3
56571
by: Steven de Vries | last post by:
Hi, I'am trying a very simple sql statement but it does not work. I use the SQL version 8.0 I use the "Northwind" sample database and the Table "Employees". The sql statement is: SELECT * From Employees Where City = "London"
4
1436
by: rawheiser | last post by:
Behavior I found: Invalid Column name in select embedded in a IN() clause appears to return a NULL, and fails silently - completing the query giving incorrect results. Behavior I expected: RunTime error, as column didn't exist.
2
2230
by: adams114 | last post by:
I am having a strange problem with invalid type casts. I am trying to update a MS SQL Database with a stored procedure. When I setup the parameters collection for the command object I get a invalid cast exception error: Compiler Error Message: BC30311: Value of type 'Date' cannot be converted to 'Integer'. The real problem here is that...
3
2004
by: graphicsxp | last post by:
Hi, I have a SQL stored procedure which looks like that: SELECT @QuerySQL = 'SELECT as LookupField, G.GroupDesc + ' + '" : "' + ' + as DescField FROM ' + 'JOIN ItemGrouping IG on IG.CatID =' + cast(@CatID as varchar(50)) + 'and ItemID = JOIN G on G.GroupID = IG.GroupID ORDER BY DescField'
9
2765
by: mark4asp | last post by:
Why is this page invalid? Pasted into http://validator.w3.org/ I'm told that the page is invalid. Why? It flags problems with the <bodyand </htmltags but I can't see why. Is the W3C validator broke is or it my page? If it's my page then what's wrong with it? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://...
3
5364
by: josna | last post by:
I am trying to execute following query but i am getting a sql exception i do not understand where i went wrong. it is saying invalid column name but i have given all fields and table names correctly, please help me out. java.sql.SQLException: ORA-00904: invalid column name rs=st.executeQuery("SELECT...
5
8015
by: Anne | last post by:
Hello! Here is the statement in question: --STATEMENT A SELECT * FROM dbo.myTable WHERE colX in (SELECT colX FROM dbo.sourceTable) The problem with Statement A is that 'colX' does not exist in 'dbo.sourceTable'. It does, however, certainly exist in 'dbo.myTable'. Breaking the statement down, we have:
0
7402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7590
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7733
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7684
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5264
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3388
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1814
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.