Author |
Topic |
jfm
Posting Yak Master
145 Posts |
Posted - 2013-05-02 : 06:32:35
|
Hi there, Im working with two different tables: t_at_bt_a has some rows in col_1 with '*' as a valuet_b has the correct values for the rows ('*') in t_a, col_1 I need to copy the values of t_b in t_a when t_a, col_1 has '*' as a valueAny tip? Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-02 : 07:04:08
|
[code]update aset a.col_1 = b.col_1from t_a ainner join t_b bon b.relatedcolumn = a.relatedcolwhere a.col_1='*'[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
jfm
Posting Yak Master
145 Posts |
Posted - 2013-05-02 : 07:28:51
|
Hi visakh16, thanks for your help. I have an error msg: msg 4104, level 16, state 1, line 1The multi-part identifier 'a.col_1' could not be bound.I do have that column in that file. I dont understand what's wrong..Any idea?Thank youquote: Originally posted by visakh16
update aset a.col_1 = b.col_1from t_a ainner join t_b bon b.relatedcolumn = a.relatedcolwhere a.col_1='*' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
|
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-02 : 07:32:44
|
file? do you mean t_a is a file and not a table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
jfm
Posting Yak Master
145 Posts |
Posted - 2013-05-02 : 08:42:59
|
Sorry, Yes, in that table not file. quote: Originally posted by visakh16 file? do you mean t_a is a file and not a table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
|
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-05-02 : 08:46:21
|
some where you are misusing column name... can you post your complete query once...?--Chandu |
|
|
jfm
Posting Yak Master
145 Posts |
Posted - 2013-05-02 : 09:03:11
|
Sure, This is my query: update Sset s.PP = b.PP from S as sinner join pp_wr as bon s.I_CN = b.I_CNand s.S_N = b.S_Nand s.IS = b.ISand s.I_D = I_Datewhere s.PP = '*' quote: Originally posted by bandi some where you are misusing column name... can you post your complete query once...?--Chandu
|
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-05-02 : 09:19:44
|
try like this... If not, post us the columns of both tables separatleyupdate a1set a1.PP = b.PP from S as a1inner join pp_wr as bon a1.I_CN = b.I_CNand a1.S_N = b.S_Nand a1.IS = b.ISand a1.I_D = I_Datewhere a1.PP = '*'--Chandu |
|
|
jfm
Posting Yak Master
145 Posts |
Posted - 2013-05-02 : 09:44:53
|
chandu, I might be wrong but I think the query is the same as mine.. thanks 0quote: Originally posted by bandi try like this... If not, post us the columns of both tables separatleyupdate a1set a1.PP = b.PP from S as a1inner join pp_wr as bon a1.I_CN = b.I_CNand a1.S_N = b.S_Nand a1.IS = b.ISand a1.I_D = I_Datewhere a1.PP = '*'--Chandu
|
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-05-02 : 14:35:06
|
quote: Originally posted by jfm Sure, This is my query: update Sset s.PP = b.PP from S as sinner join pp_wr as bon s.I_CN = b.I_CNand s.S_N = b.S_Nand s.IS = b.ISand s.I_D = I_Datewhere s.PP = '*' quote: Originally posted by bandi some where you are misusing column name... can you post your complete query once...?--Chandu
Are you sure you're getting the specified error message by executing this query??? I think you should not be getting it. As I don't see a.col_1 used anywhere in this query CheersMIK |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-03 : 00:34:01
|
quote: Originally posted by jfm Sure, This is my query: update Sset s.PP = b.PP from S as sinner join pp_wr as bon s.I_CN = b.I_CNand s.S_N = b.S_Nand s.IS = b.ISand s.I_D = I_Datewhere s.PP = '*' quote: Originally posted by bandi some where you are misusing column name... can you post your complete query once...?--Chandu
check if all the columns specified are available in the corresponding tables.You can use INFORMATION_SCHEMA.COLUMNS view for that------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|