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
 General SQL Server Forums
 New to SQL Server Programming
 filtering bad data

Author  Topic 

sanjnep
Posting Yak Master

191 Posts

Posted - 2007-09-24 : 11:06:19
Hi,
I have following query. I want to insert the value MBR_COV_EFF_DATE
to table fixed_MM if the function dbo.CheckTheDate2 returns correct date and if it returns NULL I want to insert it on error_MM table.
How can I do this?

select dbo.CheckTheDate2(MBR_COV_EFF_DATE,'MBR_COV_EFF_DATE') AS MBR_COV_EFF_DATE
from [unfixed_MM]


Thanks
Sanjeev

Kristen
Test

22859 Posts

Posted - 2007-09-24 : 11:08:36
I would do:

select dbo.CheckTheDate2(MBR_COV_EFF_DATE,'MBR_COV_EFF_DATE') AS MBR_COV_EFF_DATE, *
INTO #TEMP
FROM from [unfixed_MM]

INSERT INTO fixed_MM
SELECT *
FROM #TEMP
WHERE MBR_COV_EFF_DATE IS NOT NULL

INSERT INTO error_MM
SELECT *
FROM #TEMP
WHERE MBR_COV_EFF_DATE IS NULL

DROP TABLE #TEMP

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-25 : 03:54:49
What do you mean by correct date?


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -