Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 HAVE PROBLEM need help

Author  Topic 

zeitoun
Starting Member

5 Posts

Posted - 2008-09-19 : 13:57:36
need help
have a problen when i write this sentences i trans-sql

i need to update only 1 rows in diferente tables

this the sentences

use adn_coopemap
UPDATE dbo.chd_cheques_detalle
SET CHD_Cheques_Detalle.CHE_Codigo = COM_Compania.COM_Codigo
FROM CHD_Cheques_Detalle,COM_Compania
WHERE CHD_Cheques_Detalle.CHE_Codigo 5900A and COM_Compania.COM_Codigo 1
GO

and
this errors

Msg 1032, Level 15, State 1, Line 3
Cannot use the column prefix 'CHD_Cheques_Detalle'. This must match the object in the UPDATE clause 'dbo.chd_cheques_detalle'.
Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '5900'.

all gurus in sql trans-sql please help thanks

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2008-09-19 : 14:03:27
This is basically just setting Checkes_Detail = 1, are you sure this is what you want

UPDATE a
SET a.CHE_Codigo = b.COM_Codigo
FROM
CHD_Cheques_Detallea a
Cross Join
COM_Compania b
WHERE a.CHE_Codigo = 5900A
and b.COM_Codigo = 1


If so use


UPDATE a
SET a.CHE_Codigo = 1
FROM
CHD_Cheques_Detallea a
WHERE a.CHE_Codigo = 5900A



Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-19 : 14:03:31
may be this

use adn_coopemap
UPDATE cd
SET cd.CHE_Codigo = cc.COM_Codigo
FROM CHD_Cheques_Detalle cd
JOIN COM_Compania cc
ON cd.[CHE_Codigo 5900A] =cc.[COM_Codigo 1]
GO
Go to Top of Page

zeitoun
Starting Member

5 Posts

Posted - 2008-09-19 : 14:56:13
quote:
Originally posted by Vinnie881

This is basically just setting Checkes_Detail = 1, are you sure this is what you want

UPDATE a
SET a.CHE_Codigo = b.COM_Codigo
FROM
CHD_Cheques_Detallea a
Cross Join
COM_Compania b
WHERE a.CHE_Codigo = 5900A
and b.COM_Codigo = 1


If so use


UPDATE a
SET a.CHE_Codigo = 1
FROM
CHD_Cheques_Detallea a
WHERE a.CHE_Codigo = 5900A



Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881



ok really what I want is to update the table is called dbo.chd_cheques_detalle but to update this table and the corresponding row also update another table that there is a field that is not on the table if not on my table com_compania

besides the basic problem is that need solving a problem with a check that had a code that now has to cambierce by a user entered the wrong code and the system will

spelling Excuse me please
Go to Top of Page

zeitoun
Starting Member

5 Posts

Posted - 2008-09-19 : 14:56:13
quote:
Originally posted by Vinnie881

This is basically just setting Checkes_Detail = 1, are you sure this is what you want

UPDATE a
SET a.CHE_Codigo = b.COM_Codigo
FROM
CHD_Cheques_Detallea a
Cross Join
COM_Compania b
WHERE a.CHE_Codigo = 5900A
and b.COM_Codigo = 1


If so use


UPDATE a
SET a.CHE_Codigo = 1
FROM
CHD_Cheques_Detallea a
WHERE a.CHE_Codigo = 5900A



Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881



ok really what I want is to update the table is called dbo.chd_cheques_detalle but to update this table and the corresponding row also update another table that there is a field that is not on the table if not on my table com_compania

besides the basic problem is that need solving a problem with a check that had a code that now has to cambierce by a user entered the wrong code and the system will

spelling Excuse me please
Go to Top of Page

zeitoun
Starting Member

5 Posts

Posted - 2008-09-19 : 15:10:13
quote:
Originally posted by visakh16

may be this

use adn_coopemap
UPDATE cd
SET cd.CHE_Codigo = cc.COM_Codigo
FROM CHD_Cheques_Detalle cd
JOIN COM_Compania cc
ON cd.[CHE_Codigo 5900A] =cc.[COM_Codigo 1]
GO




use adn_coopemap
UPDATE CHD_Cheques_Detalle
SET CHD_Cheques_Detalle.CHE_Codigo = COM_Compania.COM_Codigo
FROM CHD_Cheques_Detalle
JOIN COM_Compania
ON CHD_Cheques_Detalle.[CHE_Codigo 5900A] = COM_Compania.[COM_Codigo 1]
GO

errors:

Msg 207, Level 16, State 3, Line 3
Invalid column name 'CHE_Codigo 5900A'.
Msg 207, Level 16, State 3, Line 3
Invalid column name 'COM_Codigo 1'.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-20 : 01:51:37
quote:
Originally posted by zeitoun

quote:
Originally posted by visakh16

may be this

use adn_coopemap
UPDATE cd
SET cd.CHE_Codigo = cc.COM_Codigo
FROM CHD_Cheques_Detalle cd
JOIN COM_Compania cc
ON cd.[CHE_Codigo 5900A] =cc.[COM_Codigo 1]
GO




use adn_coopemap
UPDATE CHD_Cheques_Detalle
SET CHD_Cheques_Detalle.CHE_Codigo = COM_Compania.COM_Codigo
FROM CHD_Cheques_Detalle
JOIN COM_Compania
ON CHD_Cheques_Detalle.[CHE_Codigo 5900A] = COM_Compania.[COM_Codigo 1]
GO

errors:

Msg 207, Level 16, State 3, Line 3
Invalid column name 'CHE_Codigo 5900A'.
Msg 207, Level 16, State 3, Line 3
Invalid column name 'COM_Codigo 1'.



ok. so you dont have columns CHE_Codigo 5900A... so where you trying update the column CHE_Codigo with 5900A,...Sorry it wasnt clear from your original post. Can you explain what you're really looking for.
Go to Top of Page

zeitoun
Starting Member

5 Posts

Posted - 2008-09-20 : 09:44:57
quote:
Originally posted by visakh16

quote:
Originally posted by zeitoun

quote:
Originally posted by visakh16

may be this

use adn_coopemap
UPDATE cd
SET cd.CHE_Codigo = cc.COM_Codigo
FROM CHD_Cheques_Detalle cd
JOIN COM_Compania cc
ON cd.[CHE_Codigo 5900A] =cc.[COM_Codigo 1]
GO




use adn_coopemap
UPDATE CHD_Cheques_Detalle
SET CHD_Cheques_Detalle.CHE_Codigo = COM_Compania.COM_Codigo
FROM CHD_Cheques_Detalle
JOIN COM_Compania
ON CHD_Cheques_Detalle.[CHE_Codigo 5900A] = COM_Compania.[COM_Codigo 1]
GO

errors:

Msg 207, Level 16, State 3, Line 3
Invalid column name 'CHE_Codigo 5900A'.
Msg 207, Level 16, State 3, Line 3
Invalid column name 'COM_Codigo 1'.



ok. so you dont have columns CHE_Codigo 5900A... so where you trying update the column CHE_Codigo with 5900A,...Sorry it wasnt clear from your original post. Can you explain what you're really looking for.


ok is a need to update the table CHD_Cheques_Detalle a number of check n truth because in a program that does have one problem that a user entered a check estva already in the database and the system error could happen but now I leave when I Change my checking transactions problem of replica of what I want to check and replace with an update otherwise key fields in my project are the che_codigo and com_codigo but com_codigo belongs to a field that is not within dela table CHD_Cheques_Detalle if not this com_compania in the table and that is my issue that I can not update
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-21 : 02:16:50
sorry not fully understood yet from your verbal explanation . can you illustrate with some sample data please?
Go to Top of Page
   

- Advertisement -