locked
error occurred in procedure RRS feed

  • Question

  • User-1634604574 posted

    i have this procedure i get error near +

    alter proc read_file
    @css varchar(max)=null,
    @js varchar(max)
    
    as begin
    declare @css2 varchar(max)
    
    set @css2=(select '"c:\temp\' + @css+  '.css"')
    set @js=(select @js+'.js')
    
    create table #TempTable (line varchar(max))
    bulk insert #TempTable from  'c:\temp\"'+@css+'".css'
    
    
    
    DECLARE @combinedString VARCHAR(MAX)
    SELECT @combinedString = COALESCE(@combinedString + CHAR(13)+CHAR(10), '') + line
    FROM #TempTable
    
    
    SELECT @combinedString as StringValue 
    drop table #TempTable
    
    end

    Tuesday, October 1, 2019 11:39 AM

Answers

  • User475983607 posted

    The FROM clause cannot be dynamic.  You'll need to make the whole SQL script dynamic.

    DECLARE @sql VARCHAR(max) = 'create table #TempTable (line varchar(max)) ' + 
    ' bulk insert #TempTable from  c:\temp\' + @css + '.css'

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 1, 2019 12:02 PM