I have a ftp site and want to bulk insert comma deliminated files. I have a table which has the Municipalities name and I create a parameter which is the name + current date in a certain format. The Muni_table controls which Municipalities are ftp and needs loaded. I use a cursor to run through the table and pick out the @Name value. All of this works perfectly. I then try to use the @Filename for the from section of Bulk Insert but it errors saying it expects Integer, String, ID, etc etc. How can I use the @filename to pull the files in? Here is my code.Declare @FileName as varchar(max)Declare MuniCursor Cursor Fast_ForwardforSelect Muni_Name from muni_information where Active = 1 and configuration_Type = 'FTP'Declare @Name as varchar(max)Open MuniCursorfetch Next from MuniCursor into @NameWhile (@@FETCH_STATUS <> -1)Beginif (@@FETCH_STATUS <> -2)Set @FileName = 'C:\' + @Name + '_' + convert(varchar(2),DATEPART(mm,getdate()))+ '_' + convert(varchar(2),DATEPART(DD,GETDATE())) + '_' + CONVERT(varchar(4), DATEPART(YY,getdate())) + '.txt'bulk insert Initial_DataLoadfrom @FileNamewith (ROWTERMINATOR = '\n', FieldTerminator = '\t')Fetch Next From MuniCursor into @NameEndClose MuniCursorDeallocate MuniCursorgo
bulk insert Initial_DataLoadfrom @FileNamewith (ROWTERMINATOR = '\n', FieldTerminator = '\t')Fetch Next From MuniCursor into @NameEndIs the trouble part the from @filename throws the error.Thanks for help