Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 joint 2 files to one new file.

Author  Topic 

ronalberts
Starting Member

2 Posts

Posted - 2004-01-27 : 03:29:05
I need to know wheter it is possible to join to files together to a (temporary) file. File A contains a field NUMBER and several fields containing Name, Adres, etc. File B contains also a field NUMBER and a field with AMOUNT.

Now, we would like to join these two files to one new file that contains all the fields from file A but additional the field AMOUNT where the field NUMBER mact on both files.

Can this be done by using SQL ? Looking forward to some help !

Note: We use SQL on an IBM iseries system.

Kind regards,

Ron

rihardh
Constraint Violating Yak Guru

307 Posts

Posted - 2004-01-27 : 04:04:43
What do you mean by "file"? And be carefull with the use of "joint".
Go to Top of Page

ronalberts
Starting Member

2 Posts

Posted - 2004-01-27 : 04:42:54
By file I mean a file containing records.
example:

File Client
Containing record custnbr, name, adres, telnbr, etc.

Note: this is on an IBM iseries, not a PC file but I don´t think that´s an issue. SQL is mostly the same.
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-01-27 : 05:33:31
You need to get your terminology/technology right 1st.
This site is primarily orientated towards MicroSoft SQL Server.

Tables....not files...files here are things that can be opened in Notepad, Excel + MS Word.

Search here and BOL (Books Online - comes with MS SQL)....for "inner join" and "left join"...you'll see plenty of examples that may help you along your way.

Your description is also a bit brief....usually we'd like to see the definition of both tables, some sample input data and some sample expected results....what advice we offer is free, however it does help to help us AS MUCH as possible.
Go to Top of Page

rihardh
Constraint Violating Yak Guru

307 Posts

Posted - 2004-01-28 : 03:35:34
We all have seen a server, thank you. It's that big black box standing in a corner and giving us lots of headache.

What kind of OS does it run on and what kind of DB holds your data?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-01-28 : 12:22:01
You can concatenate files together using the type command in DOS. For instance:

type *.* > C:\temp\concat.txt

The above command will concatenate all files in the current directory into a file called concat.txt in the temp directory. To do it in SQL, just use xp_cmdshell with the type command.

But I think you are looking for JOIN:

SELECT a.Column1, b.ColumnA
FROM Table1 t1
INNER JOIN Table2 t2 ON t1.Column1 = t2.Column1
WHERE a.Column2 IS NOT NULL

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-01-28 : 13:03:20
Or if he is looking for a joint, it'll make merging the file that mcu harder...


"wow look at all the colors..."



Brett

8-)
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-01-28 : 13:05:46
Sorry....

Dude! What does it mean when you say you're running on IBM machine?

What type of prodcucts do you have installed?





Brett

8-)
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2004-01-28 : 14:42:01
His use of the word "file" when referring to a database table, plus running on IBM hardware, leads me to guess he is referring to ..... an AS/400 system.

Jonathan
Gaming will never be the same
Go to Top of Page
   

- Advertisement -