Solved

How to combine INSERT, EXEC master..getfiledetails, SELECT ?

Posted on 2003-12-10
6
838 Views
Last Modified: 2012-08-13
I'm newbie in SQL commands. Is possible to combine this commands?

INSERT ##filedetails
EXEC master..getfiledetails 'c:\filename.txt'
SELECT filename FROM ##filenametable

Command SELECT must be parameter of EXEC master..getfiledetails procedure and output I want to insert to ##filedetails table.

Like this: INSERT ##filedetails EXEC master..getfiledetails SELECT filename FROM ##filenametable

Thank you for response. Martin
0
Comment
Question by:martin_mmj
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:dishanf
Comment Utility
what is getfiledetails ??? it is not a system sp/
0
 

Author Comment

by:martin_mmj
Comment Utility
Ohhh, sorry. Must be master..xp_getfiledetails.

Thanks. M.

0
 
LVL 8

Expert Comment

by:dishanf
Comment Utility
Yes. you can execute lot of sql statements at ones. but I think before you run this SQL. You must create a temp table First.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:martin_mmj
Comment Utility
Yes, the table ##filedetails was created first and the table ##filenametable contains a lot of path-filenames.

If I run script

INSERT ##filedetails EXEC master..xp_getfiledetails 'c:\pagefile.sys'

one row is OK inserted to the table ##filedetails. But I want run this commands for all rows in ##filenametable.

Can you help me? Thanks. M.
0
 
LVL 8

Accepted Solution

by:
dishanf earned 25 total points
Comment Utility
write cursor..

DECLARE @Filename varchar(100)

DECLARE CURSOR cur
SELECT filename FROM ##filenametable

OPEN cur

FETCH NEXT FROM cur into @Filename

WHILE @@FETCH_STATUS = 0
BEGIN
      INSERT ##filedetails EXEC master..xp_getfiledetails @Filename
      FETCH NEXT FROM cur into @Filename
END

CLOSE cur
DEALLOCATE cur
0
 

Author Comment

by:martin_mmj
Comment Utility
Thank you for idea. Now it works OK.

Martin
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now