CREATE PROC uspDIR
@Path VARCHAR(MAX)
AS
BEGIN
CREATE TABLE #DIR (
ID INT IDENTITY ( 1 , 1 ),
Line VARCHAR(512))
DECLARE @Command CHAR(2048),
@Return INT
SET @Command = 'dir "' + @Path +'"'
PRINT @Command -- test and debug
INSERT #DIR
EXECUTE @Return = master.dbo.xp_cmdshell @Command
DELETE #DIR WHERE Line is NULL
SELECT * FROM #DIR
END
GO
EXEC uspDIR 'C:\Program Files\TERACOPY'
No comments:
Post a Comment