April 8, 2013 at 3:03 am
Hello,
I need syntax to get the all the values of one employee from the employee table, in a single column of the another table .....
April 8, 2013 at 3:13 am
This is not easy without knowing more about your data and table structures.
Please follow the link in my signature to see how to post easily consumable DDL and sample data.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
April 9, 2013 at 7:56 am
andrewalex.r (4/8/2013)
Hello,I need syntax to get the all the values of one employee from the employee table, in a single column of the another table .....
Why in the world do you want to smash all your data together into a single column in a different table? There is generally no good reason for something like that.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 9, 2013 at 3:00 pm
Phil & Sean both are right but you can use something like this..
Insert into Table2 (col3)
Select col1 + ' ' + col2 from table1
April 9, 2013 at 3:04 pm
dwivedi.neeraj (4/9/2013)
Phil & Sean both are right but you can use something like this..Insert into Table2 (col3)
Select col1 + ' ' + col2 from table1
dwivedi.neeraj's approach will work pretty much. Keep in mind that you probably need to wrap each column with an ISNULL or the entire results will be NULL.
Insert into Table2 (col3)
Select isnull(col1, '') + ' ' + isnull(col2, '') from table1
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply