I need to put a filename that is already listed into a table. I need to put the filename to address to access the file.
I already tried this:
DECLARE @filename AS varchar(255) DECLARE @filepath AS varchar (255) --SELECT MAX(id) FROM ##TempFileName SET @filename = 'SELECT tfn.subdirectory FROM ##TempFileName tfn WHERE id = ''1''' EXEC (@filename) --PRINT @filename set @filepath = 'D:romliLockAmount_out' + @filename + '.txt' EXEC (@filepath) PRINT @filepath
I expect @filepath
will contain something like this D:romliLockAmount_out123456.txt
, how I can store the filename in a table to store in a variable?
Advertisement
Answer
Seeing that you want two different variables : @filename and @filepath, you can assign them on the same query.
select @filename = tfn.subdirectory, @filepath = 'D:romliLockAmount_out' + tfn.subdirectory + '.txt' from ##TempFileName tfn where tfn.id = '1'