joebickley
Programmer
Hi
Im trying to create a proc to update a single field in a table, but that field can be different each time. ie i pass in the field name and the value i want it to be set to. What i have tried to do build and SQL statement into a string and execute it. This works but only from SQL server not from the .ASP page i want it to work from. I think its something to do with QUOTED_IDENTIFIER.
Heres my code, any ideas or alternative methods for doing this?
create Procedure dbo.SP_UpdateSingleField
@colname nvarchar(50),
@colvalue nvarchar(50)
as
set QUOTED_IDENTIFIER OFF
declare @sqltext nvarchar(500)
set @sqltext = 'update tbl_claimdata set ' + @colname + ' = "' + @colvalue + '" where referencenumber = 2'
exec (@sqltext)
Thanks
Joe
Im trying to create a proc to update a single field in a table, but that field can be different each time. ie i pass in the field name and the value i want it to be set to. What i have tried to do build and SQL statement into a string and execute it. This works but only from SQL server not from the .ASP page i want it to work from. I think its something to do with QUOTED_IDENTIFIER.
Heres my code, any ideas or alternative methods for doing this?
create Procedure dbo.SP_UpdateSingleField
@colname nvarchar(50),
@colvalue nvarchar(50)
as
set QUOTED_IDENTIFIER OFF
declare @sqltext nvarchar(500)
set @sqltext = 'update tbl_claimdata set ' + @colname + ' = "' + @colvalue + '" where referencenumber = 2'
exec (@sqltext)
Thanks
Joe