ironcurtain Posted September 1, 2012 Share Posted September 1, 2012 While trying to run below query I got error: Incorrect syntax near '+'. declare @filepath varchar(50)set @filepath = 'e:\tsql\'create table #tab1 (name varchar(100))insert #tab1 exec master..xp_cmdshell 'dir /b "'+@filepath'"+"'*.txt'"' I think there is issue with quatation marks but I couldn't find any solution. Please help. Link to comment Share on other sites More sharing options...
ironcurtain Posted September 2, 2012 Author Share Posted September 2, 2012 I founded solution for above: declare @filepath varchar(50)set @filepath = 'e:\tsql\'declare @filetype varchar(5)set @filetype = 'txt'declare @commamd varchar(50)set @commamd = 'dir /b '+@filepath+@filetypecreate table #tab1 (name varchar(100))insert #tab1 exec master..xp_cmdshell @command Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now