Click here to Skip to main content
15,921,250 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
hello,
i want to concat column values and stored into separate table from diifernt tables.can u guide or send any snippets
Posted
Comments
Sergey Alexandrovich Kryukov 28-Feb-12 21:48pm    
First, this is not a question. Also, you need to define your "concat". In usual terminology, "concatenation" is not something which can be applied to columns; it is applied to strings, texts.
--SA

Not terribly difficult

SQL
DECLARE @value1 NVARCHAR
DECLARE @value2 NVARCHAR

SELECT @value1 = column FROM table1 WHERE ...
SELECT @value2 = column FROM table2 WHERE ...

INSERT INTO table3(columns) VALUES(@value1 + @value2)
 
Share this answer
 
Are talking about String Concatination ?
 
Share this answer
 
hi there...
is there is any common column in both table, if it is there then it is possible.
first u take columns from both table using join and insert into temp table, and now from temp table u can concat two columns in one column value.


INSERT INTO #ConCatTable(col1_tab1,col2_tab2)
SELECT t1.col1_tab1,t2.col2_tab2 FROM table1 t1 join table2 t2
ONt1.common_colm = t2.comon_colm


SELECT RTRIM(col1_tab1)+'_'+LTRIM(col1_tab2) FROM #ConCatTable
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900