|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
Hi all,I want to produce some output for Mainframe application. For that I want to insert values from multiple table as source to a single column (huge in size)of a different table (Destination table). There may be same related records in all of the source tables with the primary key. When I export values from the source tables , each related records should be insterted to the destination table's field (multiple entries for each table). Please advise. Thanks |
|
#2
|
||||
|
||||
|
you mean UPDATE a column, not INSERT, right?
because if you insert values into a column, all the other columns in the destination table will be null or default |
|
#3
|
|||
|
|||
|
Quote:
Hi, Thanks for the quick reply. Yes it should be null. Actully I want to produce a text file output from multiple tables using where condition. The exact column width should be reflected for each colum on the text file. The column should not be seperated by comma, tab or a space. The next column shoul start exactly after the previous column ends. If i can export all the values from multiple table the single column of the destination (Concatening the column, Like col1 + col2 + col3 so on) I would be able to produce the desired result. As if now, I am able to extract values from only one table as if now. Please advise if I can export values from multiple tables to a single colum of a destination table at once. |
|
#4
|
||||
|
||||
|
okay, yes, you can do this
you need concatenation, like col1 + col2 + col3 you also need conversion to fixed width for any varchar columns, like convert(char(25),varcharfield) |
|
#5
|
|||
|
|||
|
Quote:
You can construct the query as follows say you have 2 tables called order and invoice SELECT CONVERT(VARCHAR,o.orderid) + ' ' + CONVERT(VARCHAR,i.invoiceid) + ' ' + o.customername,CONVERT(VARCHAR,i.invoicedate) AS CustomerDetail INTO LogCustomerDetails FROM order o, invoice i WHERE o.orderid = i.invoiceid I think this should solve your problem. |
|
#6
|
||||
|
||||
|
lvramani, conversion to CHAR with a specific width is required, not VARCHAR
also, specify a style for the date conversion |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Inserting Values from multiple tables to only one column of a seperate table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|