Solved

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

Posted on 2003-12-10
6
839 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
ID: 9910940
what is getfiledetails ??? it is not a system sp/
0
 

Author Comment

by:martin_mmj
ID: 9910959
Ohhh, sorry. Must be master..xp_getfiledetails.

Thanks. M.

0
 
LVL 8

Expert Comment

by:dishanf
ID: 9911012
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:martin_mmj
ID: 9911084
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
ID: 9911135
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
ID: 9911261
Thank you for idea. Now it works OK.

Martin
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

920 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

16 Experts available now in Live!

Get 1:1 Help Now