Author |
Topic |
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-22 : 06:32:27
|
I have the following code but i have the error message that the Msg 4104, Level 16, State 1, Line 4The multi-part identifier "AMPPU_ARTPU.offline_date1" could not be bound."i have this error message in uinsert into AMPPU_ARTPU(summeofrepairtime,[offline date])(select SUM(Reparatur_hr)*60,Offline_date from AMPPU_Alle_Fehlteile group by Offline_date);update AMPPU_Alle_Fehlteilesetsumme = (select summeofrepairtime from AMPPU_ARTPU)where AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1;please help methaks |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-22 : 08:12:55
|
Does the table AMPPU_ARTPU have a column named offline_date1? It is complaining about the part marked in red belowquote: Originally posted by mana I have the following code but i have the error message that the Msg 4104, Level 16, State 1, Line 4The multi-part identifier "AMPPU_ARTPU.offline_date1" could not be bound."i have this error message in uinsert into AMPPU_ARTPU(summeofrepairtime,[offline date])(select SUM(Reparatur_hr)*60,Offline_date from AMPPU_Alle_Fehlteile group by Offline_date);update AMPPU_Alle_Fehlteilesetsumme = (select summeofrepairtime from AMPPU_ARTPU)where AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1;please help methaks
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-22 : 08:27:26
|
yes it has this column. yes the problem is related to red partquote: Originally posted by James K Does the table AMPPU_ARTPU have a column named offline_date1? It is complaining about the part marked in red belowquote: Originally posted by mana I have the following code but i have the error message that the Msg 4104, Level 16, State 1, Line 4The multi-part identifier "AMPPU_ARTPU.offline_date1" could not be bound."i have this error message in uinsert into AMPPU_ARTPU(summeofrepairtime,[offline date])(select SUM(Reparatur_hr)*60,Offline_date from AMPPU_Alle_Fehlteile group by Offline_date);update AMPPU_Alle_Fehlteilesetsumme = (select summeofrepairtime from AMPPU_ARTPU)where AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1;please help methaks
|
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-22 : 10:15:04
|
I had missed an extra bracket you had. Assuming you are trying to update the column summe for every row in table AMPPU_Alle_Fehlteile with value in the column summeofrepairtime from table AMPPU_ARTPU that satisfy the condition that AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1, then you can use the following codeUPDATE f SET summe = summeofrepairtimeFROM AMPPU_Alle_Fehlteile f INNER JOIN AMPPU_ARTPU a ON f.Offline_date = a.offline_date1; |
|
|
MichaelJSQL
Constraint Violating Yak Guru
252 Posts |
Posted - 2014-07-22 : 10:22:44
|
You are trying to access a table that is aliased inside the set .(select summeofrepairtime from AMPPU_ARTPU). Try writing your statement like this and you should not get the error.update AMPPU_Alle_Fehlteileset summe =AMPPU_ARTP.summeofrepairtime FROM AMPPU_Alle_Fehlteile INNER JOIN AMPPU_ARTPU ON AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1; |
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 03:20:48
|
thank younow it worksbut when i want to update the table AMPPU_Alle_Fehlteile directly i have the below message:Msg 207, Level 16, State 1, Line 2Ungültiger Spaltenname 'summenew1'.column summenew1 is unvalidmy code is like belowUPDATE AMPPU_Alle_Fehlteile SET summenew1 = (select SUM(Reparatur_hr)*60FROM AMPPU_Alle_Fehlteile group by Offline_date);also i want that this update will be done automatically every day do you know what i can dothank you for your help quote: Originally posted by James K I had missed an extra bracket you had. Assuming you are trying to update the column summe for every row in table AMPPU_Alle_Fehlteile with value in the column summeofrepairtime from table AMPPU_ARTPU that satisfy the condition that AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1, then you can use the following codeUPDATE f SET summe = summeofrepairtimeFROM AMPPU_Alle_Fehlteile f INNER JOIN AMPPU_ARTPU a ON f.Offline_date = a.offline_date1;
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 03:22:11
|
thank younow it worksbut i have the below problemquote: Originally posted by mana thank younow it worksbut when i want to update the table AMPPU_Alle_Fehlteile directly i have the below message:Msg 207, Level 16, State 1, Line 2Ungültiger Spaltenname 'summenew1'.column summenew1 is unvalidmy code is like belowUPDATE AMPPU_Alle_Fehlteile SET summenew1 = (select SUM(Reparatur_hr)*60FROM AMPPU_Alle_Fehlteile group by Offline_date);also i want that this update will be done automatically every day do you know what i can dothank you for your help quote: Originally posted by James K I had missed an extra bracket you had. Assuming you are trying to update the column summe for every row in table AMPPU_Alle_Fehlteile with value in the column summeofrepairtime from table AMPPU_ARTPU that satisfy the condition that AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1, then you can use the following codeUPDATE f SET summe = summeofrepairtimeFROM AMPPU_Alle_Fehlteile f INNER JOIN AMPPU_ARTPU a ON f.Offline_date = a.offline_date1;
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 04:30:20
|
now i have this code and below error;UPDATE AMPPU_Alle_Fehlteile SET summenew = (select SUM(Reparatur_hr)*60FROM AMPPU_Alle_Fehlteile where Offline_date is not null group by Offline_date);Msg 512, Level 16, State 1, Line 1The subquery returned more than one value. This is not permitted when the subquery follows =,! =, <, <=,> Or> = follows or is used as an expression.i'm new to sql servercan you help me please?thank youquote: Originally posted by mana thank younow it worksbut when i want to update the table AMPPU_Alle_Fehlteile directly i have the below message:Msg 207, Level 16, State 1, Line 2Ungültiger Spaltenname 'summenew1'.column summenew1 is unvalidmy code is like belowUPDATE AMPPU_Alle_Fehlteile SET summenew1 = (select SUM(Reparatur_hr)*60FROM AMPPU_Alle_Fehlteile group by Offline_date);also i want that this update will be done automatically every day do you know what i can dothank you for your help quote: Originally posted by James K I had missed an extra bracket you had. Assuming you are trying to update the column summe for every row in table AMPPU_Alle_Fehlteile with value in the column summeofrepairtime from table AMPPU_ARTPU that satisfy the condition that AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1, then you can use the following codeUPDATE f SET summe = summeofrepairtimeFROM AMPPU_Alle_Fehlteile f INNER JOIN AMPPU_ARTPU a ON f.Offline_date = a.offline_date1;
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 05:28:50
|
and this time i get this error:Msg 164, Level 15, State 1, Line 5Each GROUP BY expression must contain at least one column that is not an outer reference.quote: Originally posted by mana now i have this code and below error;UPDATE AMPPU_Alle_Fehlteile SET summenew = (select SUM(Reparatur_hr)*60FROM AMPPU_Alle_Fehlteile where Offline_date is not null group by Offline_date);Msg 512, Level 16, State 1, Line 1The subquery returned more than one value. This is not permitted when the subquery follows =,! =, <, <=,> Or> = follows or is used as an expression.i'm new to sql servercan you help me please?thank youquote: Originally posted by mana thank younow it worksbut when i want to update the table AMPPU_Alle_Fehlteile directly i have the below message:Msg 207, Level 16, State 1, Line 2Ungültiger Spaltenname 'summenew1'.column summenew1 is unvalidmy code is like belowUPDATE AMPPU_Alle_Fehlteile SET summenew1 = (select SUM(Reparatur_hr)*60FROM AMPPU_Alle_Fehlteile group by Offline_date);also i want that this update will be done automatically every day do you know what i can dothank you for your help quote: Originally posted by James K I had missed an extra bracket you had. Assuming you are trying to update the column summe for every row in table AMPPU_Alle_Fehlteile with value in the column summeofrepairtime from table AMPPU_ARTPU that satisfy the condition that AMPPU_Alle_Fehlteile.Offline_date = AMPPU_ARTPU.offline_date1, then you can use the following codeUPDATE f SET summe = summeofrepairtimeFROM AMPPU_Alle_Fehlteile f INNER JOIN AMPPU_ARTPU a ON f.Offline_date = a.offline_date1;
|
|
|
MichaelJSQL
Constraint Violating Yak Guru
252 Posts |
Posted - 2014-07-23 : 06:17:52
|
Try the following UPDATE AMPPU_Alle_Fehlteile SET summenew1 = B.SUpdateColSource FROM #AMPPU_Alle_Fehlteile A This is going to set the summenew1 for a given date to the sum of Reparatur_hr * 60 for all records in that table with the same date. So every date that is the same will have the same value. Is that what you are trying to do? INNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROM AMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date; |
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 07:26:47
|
thank you very much now it works and i want that the following queries will be done automatically every day, should i write a job for them?update fsetnumberofdevices = Orders_DailyVolumefrom AMPPU_Fehlerdaten_CalcVals ajoin AMPPU_Alle_Fehlteile fon f.Offline_date = a.Offline_datewhere f.Offline_date is not null; -------------------------------------------------UPDATE AMPPU_Alle_Fehlteile SET summenew = B.SUpdateColSourceFROM AMPPU_Alle_Fehlteile AINNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROMAMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;---------------------------------------------------- UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDquote: Originally posted by MichaelJSQL Try the following UPDATE AMPPU_Alle_Fehlteile SET summenew1 = B.SUpdateColSource FROM #AMPPU_Alle_Fehlteile A This is going to set the summenew1 for a given date to the sum of Reparatur_hr * 60 for all records in that table with the same date. So every date that is the same will have the same value. Is that what you are trying to do? INNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROM AMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 07:30:00
|
and the tables in my sql server are linked to the access database i think.How can i update the changes in sql server in access daatbase as well?quote: Originally posted by mana thank you very much now it works and i want that the following queries will be done automatically every day, should i write a job for them?update fsetnumberofdevices = Orders_DailyVolumefrom AMPPU_Fehlerdaten_CalcVals ajoin AMPPU_Alle_Fehlteile fon f.Offline_date = a.Offline_datewhere f.Offline_date is not null; -------------------------------------------------UPDATE AMPPU_Alle_Fehlteile SET summenew = B.SUpdateColSourceFROM AMPPU_Alle_Fehlteile AINNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROMAMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;---------------------------------------------------- UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDquote: Originally posted by MichaelJSQL Try the following UPDATE AMPPU_Alle_Fehlteile SET summenew1 = B.SUpdateColSource FROM #AMPPU_Alle_Fehlteile A This is going to set the summenew1 for a given date to the sum of Reparatur_hr * 60 for all records in that table with the same date. So every date that is the same will have the same value. Is that what you are trying to do? INNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROM AMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 07:35:47
|
the below code also doesn't have error but i think it doesn'T work correctlyam i right in this code?UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDthank youquote: Originally posted by mana thank you very much now it works and i want that the following queries will be done automatically every day, should i write a job for them?update fsetnumberofdevices = Orders_DailyVolumefrom AMPPU_Fehlerdaten_CalcVals ajoin AMPPU_Alle_Fehlteile fon f.Offline_date = a.Offline_datewhere f.Offline_date is not null; -------------------------------------------------UPDATE AMPPU_Alle_Fehlteile SET summenew = B.SUpdateColSourceFROM AMPPU_Alle_Fehlteile AINNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROMAMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;---------------------------------------------------- UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDquote: Originally posted by MichaelJSQL Try the following UPDATE AMPPU_Alle_Fehlteile SET summenew1 = B.SUpdateColSource FROM #AMPPU_Alle_Fehlteile A This is going to set the summenew1 for a given date to the sum of Reparatur_hr * 60 for all records in that table with the same date. So every date that is the same will have the same value. Is that what you are trying to do? INNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROM AMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 07:40:38
|
i want that ARTPU will be equal to summenew/numberofdevicesquote: Originally posted by mana the below code also doesn't have error but i think it doesn'T work correctlyam i right in this code?UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDthank youquote: Originally posted by mana thank you very much now it works and i want that the following queries will be done automatically every day, should i write a job for them?update fsetnumberofdevices = Orders_DailyVolumefrom AMPPU_Fehlerdaten_CalcVals ajoin AMPPU_Alle_Fehlteile fon f.Offline_date = a.Offline_datewhere f.Offline_date is not null; -------------------------------------------------UPDATE AMPPU_Alle_Fehlteile SET summenew = B.SUpdateColSourceFROM AMPPU_Alle_Fehlteile AINNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROMAMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;---------------------------------------------------- UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDquote: Originally posted by MichaelJSQL Try the following UPDATE AMPPU_Alle_Fehlteile SET summenew1 = B.SUpdateColSource FROM #AMPPU_Alle_Fehlteile A This is going to set the summenew1 for a given date to the sum of Reparatur_hr * 60 for all records in that table with the same date. So every date that is the same will have the same value. Is that what you are trying to do? INNER JOIN (select Offline_date,SUM(Reparatur_hr)*60 SUpdateColSource FROM AMPPU_Alle_Fehlteile group by Offline_date) B ON A.Offline_date = B.Offline_date;
|
|
|
MichaelJSQL
Constraint Violating Yak Guru
252 Posts |
Posted - 2014-07-23 : 07:55:41
|
and the tables in my sql server are linked to the access database i think.How can i update the changes in sql server in access daatbase as well?Microsoft access ahs a pass through query - you might be able to copy your SQL in that or you could set up a job via sql agent on your sql server to run at a scheduled date/timeam i right in this code?UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDIs this the complete update statement? |
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 08:33:19
|
hello,thank you,yes this is the whole code. I changed some in sql server but i don't have them in access databse as well. i want to update the changes in access as well ans also want to execute the above code that i write will be run automatially every day.thank youquote: Originally posted by MichaelJSQL and the tables in my sql server are linked to the access database i think.How can i update the changes in sql server in access daatbase as well?Microsoft access ahs a pass through query - you might be able to copy your SQL in that or you could set up a job via sql agent on your sql server to run at a scheduled date/timeam i right in this code?UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDIs this the complete update statement?
|
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 09:04:26
|
I mean i added a column in sql server but it is not added to access database.quote: Originally posted by mana hello,thank you,yes this is the whole code. I changed some in sql server but i don't have them in access databse as well. i want to update the changes in access as well ans also want to execute the above code that i write will be run automatially every day.thank youquote: Originally posted by MichaelJSQL and the tables in my sql server are linked to the access database i think.How can i update the changes in sql server in access daatbase as well?Microsoft access ahs a pass through query - you might be able to copy your SQL in that or you could set up a job via sql agent on your sql server to run at a scheduled date/timeam i right in this code?UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDIs this the complete update statement?
|
|
|
MichaelJSQL
Constraint Violating Yak Guru
252 Posts |
Posted - 2014-07-23 : 09:11:05
|
UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDSo here is what your statement will be doing: Your table AMPPU_Alle_Fehlteile will have at least these columns ARTPU (your target) , numberofdevices , summenewYour update statement will act on each row. For each row it will test if numberofdevices = 0 and if it is , it will update the ARTPU column to 0. If numberofdevices is not 0, it will update ARTPU to ARTPU if ARTPU is not null. ( make sure you the records you want to update are null and do not have a value or they will not get updated) If ARTPU is null, it will update ARTPU to summenew divided by the numberofdevices. Is this what you are trying to do? If so, what is or is not happening? |
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-23 : 09:40:43
|
thank you, i checked it and now it works.do you know how can i export the changes in sql to access( i chnged the table in sql server for example added some columns in sql server but i can't see them in access database's table.quote: Originally posted by MichaelJSQL UPDATE AMPPU_Alle_Fehlteile SET ARTPU = CASE WHEN numberofdevices = 0 THEN 0 ELSE ISNULL(ARTPU, (summenew/numberofdevices)) ENDSo here is what your statement will be doing: Your table AMPPU_Alle_Fehlteile will have at least these columns ARTPU (your target) , numberofdevices , summenewYour update statement will act on each row. For each row it will test if numberofdevices = 0 and if it is , it will update the ARTPU column to 0. If numberofdevices is not 0, it will update ARTPU to ARTPU if ARTPU is not null. ( make sure you the records you want to update are null and do not have a value or they will not get updated) If ARTPU is null, it will update ARTPU to summenew divided by the numberofdevices. Is this what you are trying to do? If so, what is or is not happening?
|
|
|
MichaelJSQL
Constraint Violating Yak Guru
252 Posts |
Posted - 2014-07-23 : 12:44:48
|
If you using linked tables, you should be able to use the link table manager to refresh Or just drop the linked table in access and re-establishIf you are importing - just drop and reimport |
|
|
mana
Posting Yak Master
102 Posts |
Posted - 2014-07-24 : 03:29:46
|
thank you very much,i tried it and it works.sorry for bothering.I have the queries that i sent to you, i want that this queries will be done automatically every hour or minute. i added some columns in sql server and i want to fill them. also filling in access database. If i write a job for them, will it be ok? and if yes the access database will be also updated?quote: Originally posted by MichaelJSQL If you using linked tables, you should be able to use the link table manager to refresh Or just drop the linked table in access and re-establishIf you are importing - just drop and reimport
|
|
|
Next Page
|