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)
 Field Validation

Author  Topic 

chandrugbhatia
Starting Member

6 Posts

Posted - 2004-06-14 : 19:27:03
Here is the scenario. I have to match 2 different fields in two different tables. How do i do this in SQL please.

nr
SQLTeam MVY

12543 Posts

Posted - 2004-06-14 : 19:31:00
select *
from tbl1
join tbl2
on tbl1.fld1 = tbl2.fld2

What exactly do you want to do?

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

chandrugbhatia
Starting Member

6 Posts

Posted - 2004-06-14 : 19:45:51
Hey .. thanks.. whats happening is we have a source file with raw data in it.. which will go through an ETL (Extract Transform Load) process where it will be validated and transformed in one server. The data has to go into the target field which is in another server. We have to do a field to field validation hence we have to compare source with target and make sure the values are the same. Later i have transformations that i have to do. :( Like for example.. "The default is blank(source), this should be transformed to 'NULL'(Target)". Hence the target field should be NULL. I will have a lot more questions soon. But thanks for the start. If you know how to write the select statement for this one, please help. Thanks once again.
Go to Top of Page

chandrugbhatia
Starting Member

6 Posts

Posted - 2004-06-14 : 19:47:38
Do i write it exactly how it is below?

select *
from tbl1
join tbl2
on tbl1.fld1 = tbl2.fld2

What exactly do you want to do?

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
[/quote]
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-06-14 : 20:25:54
Look up CASE. You should build a table that has defaults and validation values to compare. You can then use CASE statements in your original INSERT statement to do both the validation/transformation and the later transformation at the same time. Of course, we're all just guessing without seeing your table structure and some sample data.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

chandrugbhatia
Starting Member

6 Posts

Posted - 2004-06-14 : 21:39:02
some data i am giving:

Source field description type length
bankcard_trades String 2

Target field description type Null option
BKCD_TRDS SMALLINT NULL

Field source Transformation Target field
bankcard_trades None BKCD_TRDS

source file: mstr.MMYY
target file: CR_EFX


so can someone confirm if i just the below select statement and submit it. I have never heard 'on'. I don't know so can you please confirm.

select *
from mstr.MMYY
join CR_EFX
on mstr.MMYY.bankcard_trades = CR_EFX.BKCD_TRDS
Go to Top of Page
   

- Advertisement -