DECLARE @FilePath VARCHAR(1000) DECLARE @FileExists int DECLARE @nulltable TABLE ( foo integer) SET @FilePath = 'C:\my\path\somefile.csv' exec master.dbo.xp_fileexist @FilePath, @FileExists OUTPUT if not @FileExists = 1 begin declare @bcpCommand varchar(255), @Result int set @bcpCommand = 'bcp "DECLARE @nulltable TABLE ( foo integer); Select * from @nulltable" queryout "' + @FilePath + '" -c -t, -T -S ' exec @Result = master..xp_cmdshell @bcpCommand --, no_output end
Replace nested-if's with proper exception-handling
-
" Why handle exceptions separately:
■ Handling exceptions separately enables you to define the main logic of
your
code together.
■ Without the use of sepa...
2 years ago
No comments:
Post a Comment