BruceThiessen
asked on
T-SQL INSERT INTO with both a STRING and an EXEC?
Can't quite seem to get the syntax right here:
INSERT INTO LinkedFiles (LinkType,FPathName) Values ('MasterID',EXEC master..xp_cmdshell 'dir "c:\custom\vehicles" /b /s')
INSERT INTO LinkedFiles (LinkType,FPathName) Values ('MasterID',EXEC master..xp_cmdshell 'dir "c:\custom\vehicles" /b /s')
ASKER
Now tells me: incorrect syntax by 'dir'
dir "c:\custom\vehicles" /b /s
ASKER
That's what I have... it's the ' before the dir that is giving me problems...
ASKER
When I ran the EXEC separately, it worked fine... now that I enclose the whole command with single quotes, that is where I am having difficulty...
ASKER
Do I need to use a temp table for the EXEC statement, then combine with my other value in a second INSERT?
ASKER
EXECUTE cannot be used as a source when inserting into a table variable...
>>Do I need to use a temp table for the EXEC statement, then combine with my other value in a second INSERT? <<
That is correct. Let me know if you need help with that.
That is correct. Let me know if you need help with that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your wonderful help. The solution is quick, smooth... and most importantly, works.
Open in new window
I think it was just missing a few ' s