Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
List of file using 'xp_cmdshell' path more then 128 char
Saddamhusen Uadanwala
Nov 23 2016 2:23 AM
261
Reply
I am trying to get list of file in a directory using sql server path having more then 128
character is not working.
DECLARE
@FilePath
varchar
(256)=
'D:\...'
,
--replace your path with a length more then 128 char
@SourceFiles
varchar
(100)=
'Test123456789*.txt'
,
@Query
varchar
(1000)
If Object_Id(
'tempdb.dbo.#FirstTable'
)
Is
NULL
CREATE
TABLE
#FirstTable (
Name
varchar
(256))
SET
QUOTED_IDENTIFIER
ON
SET
@Query =
'master.dbo.xp_cmdshell "dir '
+ @FilePath +
'\' + @SourceFiles +'
/b"'
INSERT
#FirstTable
exec
(@Query)
select
*
from
#FirstTable
truncate
table
#FirstTable
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Secure SQL Server
How To Add Class To Table InstructorCourses