这是我的脚本 - 它只是查找与人员行关联的图像文件。
现在,如果查询运行时没有明显的 .jpg,则会显示错误:
消息 4860,级别 16,状态 1,行 1
无法批量加载。文件“C:\Dev\ClientServices\Defence\RAN\Shore\Config\Photos\002054.2009469432270600.001.jpg”不存在。
有没有办法将此查询写入
IF not exists then set id_number = '002054.2009469432270427.001'
因此它将始终为没有图片的任何行显示此照片。
ALTER
procedure [dbo].[as_ngn_sp_REP_PH108_photo] (@PMKEYS nvarchar(50))
AS
---exec [as_ngn_sp_REP_PH108_photo] '8550733'
SET
NOCOUNT ON
DECLARE @PATH AS NVARCHAR(255)
DECLARE @ID_NUMBER NVARCHAR(27)
DECLARE @SQL AS NVARCHAR(MAX)
EXEC DB_GET_DB_SETTING'STAFF PICTURE FILE LOCATION', 0, @PATH OUTPUT
IF RIGHT(@PATH,1) <> '\'
SET @PATH = @PATH + '\'
SELECT @ID_NUMBER = ID_NUMBER FROM aView_person WHERE EXTRA_CODE_1 = @PMKEYS
SET @PATH = @PATH + @ID_NUMBER + '.jpg'
SET @SQL = 'SELECT ''Picture1'' [Picture], BulkColumn FROM OPENROWSET(Bulk ''' + REPLACE(@PATH,'''','''''') + ''', SINGLE_BLOB) AS RAN'
EXEC SP_EXECUTESQL @SQL