I'm trying to wrap the following in a Stored Procedure:
SELECT ( CASE WHEN ( select Count(*) FROM [dbo].[HistoryTable] WHERE MonthlyFileWritten = convert( varchar, dateadd(dd,-1,dateadd(mm, datediff(mm,0,getdate() ), 0)),112) ) <= 1 THEN declare @fullpath1 varchar(1000) OTHER STUFF HERE . . . . THIS WORKS FINE OUTSIDE OF THE CASE WHEN THEN --Insert EOM Date into History Table INSERT INTO [London_Data].[dbo].[HistoryTable]([MonthlyFileWritten]) VALUES (convert( varchar, dateadd(dd,-1,dateadd(mm, datediff(mm,0,getdate() ), 0)),112)) ELSE --PRINT 'NOTHING' END ) END GO
I've been fiddling with this for a while; still not working at all. Can you NOT use Bulk Insert with CASE WHEN THEN?
It seems like you should be able to do that!!
Any thoughts anyone?
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.