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 -
SELECT tships.[Load ],
-
tships.[Ship Id],
-
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],
-
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],
-
AS [Reason Codes3],
-
AS [XPD flag],
-
After this it the modifications that i've made -
SELECT tShips.[Load ],
-
tShips.[Ship Id],
-
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],
-
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],
-
LTrim([reason codes1] & [reason codes2]) AS [Reason Codes3],
-
CASE
-
WHEN [xpd] = 1
-
THEN 'XPD'
-
ELSE NULL
-
END AS [XPD FLAG],
-
3 1827 ck9663 2,878
Recognized Expert Specialist
What column is throwing the error? And you also missed on in -
-
LTrim([reason codes1] & [reason codes2]) AS [Reason Codes3]
-
-
Happy Coding!!!
~~ CK
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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)) '*
|
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& "'"
|
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
|
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"
|
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.
| |
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...
|
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'
|
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://...
|
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...
|
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:
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |