In my controller, I have this method:
def show
@final =final_params
allparams=''
ActiveRecord::Base.connection.execute("USE database")
ActiveRecord::Base.connection.execute("declare @p3 dbo.Params")
@final.each do |key, value|
allparams= "insert into @p3 values(N'""#{key}"+"'"++",N'"+"#{value}"+"')\n"
ActiveRecord::Base.connection.execute(allparams)
end
end
But, I am facing the below error:
TinyTds::Error: Must declare the table variable "@p3".: insert into @p3 values(N'a',N'aa')
In my above code @p3
is a table name parameter.
I am using SQL Server for database.