Reputation: 189
I need pick up first character from Column2_table1 and add it before value from Column1_table1 and this join value i would like get into emptly column Column3_table1.
I have :
Column1_table1 Column2_table1 Column3_table1
1234 abcd
1245 aeio
1545 dfaf
1545 jhui
INSERT INTO [dbo].[Table1] ([Column3_table1])
SELECT
Column1_table1,
CONCAT(left(Column2_table1,1) ,Column1_table1)
FROM Table1
Msg 121, Level 15, State 1, Line 1 The select list for the INSERT statement contains more items than the insert list. The number of SELECT values must match the number of INSERT columns.
I need
Column1_table1 Column2_table1 Column3_table1
1234 abcd a1234
1245 aeio a1245
1545 dfaf d1545
1545 jhui j1545
Thanks for help
Upvotes: 1
Views: 2685
Reputation: 29051
Try this:
UPDATE [dbo].[Table1]
SET [Column3_table1] = LEFT(Column2_table1, 1) + Column1_table1;
Upvotes: 2
Reputation: 1
try this query:
UPDATE [dbo].[Table1] SET [dbo].[Table1] ([Column3_table1]) = concat(SUBSTRING ([dbo].[Table1] ([Column2_table1]),1,1),[dbo].[Table1] ([Column1_table1]))
hope this help.
Upvotes: 0
Reputation: 63
I think this will fix your problem,
update `Table1` set `Column3_table1` = CONCAT(left(`Column2_table1`,1) ,`Column1_table1`)
Enjoy!
Upvotes: 0