July 24, 2011 at 5:05 pm
Would it be an option to get the file name list and rename it using xp_cmdshell?
July 24, 2011 at 5:30 pm
No. Because files names already exists in the database, I guess they were inserted by Front end Application. Basically it holds names and paths to the files on the disk.
Now we decided to load into the database. Hence File names I can't change. It should match in the database.
July 24, 2011 at 5:33 pm
I thought about renaming or copy the files (with a more useful file name) just for the load process...
July 24, 2011 at 5:53 pm
Do you know how I can force to accept following name in above query which contains comma
18765_McHaney,Packet,DI,4.2.10_1
July 24, 2011 at 5:57 pm
Sridoc2020 (7/24/2011)
Do you know how I can force to accept following name in above query which contains comma18765_McHaney,Packet,DI,4.2.10_1
No. Hence my recommendation to rename the files before the import.
July 24, 2011 at 7:00 pm
Sridoc2020 (7/24/2011)
Do you know how I can force to accept following name in above query which contains comma18765_McHaney,Packet,DI,4.2.10_1
At the risk of offending you, you have to start trying what I told you. The following example works just fine...
SELECT '07/14/2011 11:20 AM 31,232 The, Shadow.jpg',
'The, Shadow.jpg',
'Jul 14 2011 12:00AM',
*
FROM OPENROWSET(BULK 'C:\Documents and Settings\Admin\My Documents\My Pictures\The, Shadow.jpg' , SINGLE_BLOB) AS imagesource
--Jeff Moden
Change is inevitable... Change for the better is not.
July 25, 2011 at 8:19 am
Jeff
Yes they are working fine if you run following individually as you said. But When I am executing using EXEC ( @SQLstr) I am facing problem.
INSERT INTO dbo.MyFiles (OrignalFileName,FileName,CreationDate,file_blob)
SELECT '07/14/2011 10:56 AM 559,790 11838_send,Ortho.App.01.20.10&2.17.10_1.pdf',
'11838_SeanTownsend,Ortho.App.01.20.10&2.17.10_1.pdf',
'Jul 14 2011 12:00AM',
*
FROM OPENROWSET(BULK 'D:\DOCS\DOCS2010\11838_send,Ortho.App.01.20.10&2.17.10_1.pdf' , SINGLE_BLOB) AS imagesource
output
--------------------------------------------------------------------------------------------------------------------
The system cannot find the file specified.
'2.17.10_1.pdf' is not recognized as an internal or external command,operable program or batch file.
same above If I run from query window from SSMS, it just runs fine
INSERT INTO dbo.MyFiles (OrignalFileName,FileName,CreationDate,file_blob)
SELECT '07/14/2011 10:56 AM 559,790 11838_send,Ortho.App.01.20.10&2.17.10_1.pdf',
'11838_SeanTownsend,Ortho.App.01.20.10&2.17.10_1.pdf',
'Jul 14 2011 12:00AM',
*
FROM OPENROWSET(BULK 'D:\DOCS\DOCS2010\11838_send,Ortho.App.01.20.10&2.17.10_1.pdf' , SINGLE_BLOB) AS imagesource
Another Error, which says incorrect syntax, but runs fine from query window
INSERT INTO dbo.MyFiles (OrignalFileName,FileName,CreationDate,file_blob)
SELECT '07/14/2011 10:56 AM 103,495 12276_Fruge,Patricia1.06.10_1.pdf',
'12276_Fruge,Patricia1.06.10_1.pdf',
'Jul 14 2011 12:00AM',
*
FROM OPENROWSET(BULK 'D:\DOCS\DOCS2010\12276_Fruge,Patricia1.06.10_1.pdf' , SINGLE_BLOB) AS imagesource
output
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The syntax of the command is incorrect.
July 25, 2011 at 11:40 am
That would be a problem with your dynamic SQL. How are you doing the EXEC???
If you're using EXEC @somevariable, that's the wrong way to do it. You need to use EXEC (@somevariable).
--Jeff Moden
Change is inevitable... Change for the better is not.
July 26, 2011 at 4:06 pm
EXEC ( @SQLstr)
July 26, 2011 at 10:37 pm
I guess I'm out of tricks, then. I can't troubleshoot any further from here. My apologies.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 27, 2011 at 3:03 am
What might help is a list of 3 or 4 INSERT statements for the #CmdShell table that will show the file names you're trying to import.
We could then create files with the identical names and try to replicate your issue.
I tested your original code with
INSERT INTO #CmdShell
SELECT '12276_Fruge&Patricia1.06,10_1.pdf'
and I had no issues to bulk load that file.
July 27, 2011 at 3:05 am
Viewing 12 posts - 16 through 27 (of 27 total)
You must be logged in to reply to this topic. Login to reply