If statement problem | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

If statement problem

I am converting one of our sql 2000 machines over to sql 2005 and found that one of my import scripts is now blowing up. It looks something like this: if (select filename from db..table
where filename = ‘file.dat’) = ‘file.dat’
begin
bulk insert file
end It is blowing up on the bulk insert because the file doesn’t exist making that not a valid sql statement. The problem is that once a file arrives to us, it is a valid statement and thus works fine. It worked fine in sql 2000. Is there a setting that I’m missing or is it just not going to allow my sloppy coding any longer? Greg

s.b.
if exists (select *from db..table
where filename = ‘file.dat’) But that won’t help the error. bulk insert still doesn’t check for the existance of external files before executing so I doubt if that is the problem. Is the path you are using valud on the v2005 server? Instead of using a table to check for the existance of the file why not just check the folder to see what is there?
Nigel, it is nice to see you here [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
Yes, indeed! <br /><br />…but apparently his autosig didn’t make it from SQLTeam to here. [<img src=’/community/emoticons/emotion-5.gif’ alt=’;)‘ />]<br /><br />–<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Heute schon gebloggt?<a target="_blank" href=http://www.insidesql.de/blogs>http://www.insidesql.de/blogs</a><br />Ich unterstuetze PASS Deutschland e.V. <a target="_blank" href=http://www.sqlpass.de>http://www.sqlpass.de</a>)
Hello everyone.
I’ll get round to it.
At a company which is a bit restrictive on internet access at the moment. Can’t get to hotmail or anything that needs passport.
Snitz seems to be ok though.

]]>