sybase dynamic sql demo and quatation escape
if exists(select * from sysobjects where name = 'testjson' and type='P')
drop procedure testjson
setuser 'dbo'
go
create procedure testjson(@p varchar(200))
as
begin
print @p
select distinct siteId from AlertWebsiteTb
end
go
declare @pa varchar(10)
select @pa = 'hello'
declare @params varchar(300)
select @params = 'exec testjson @pa'
exec (@params)
-- if the params is hard-coded
declare @params varchar(300)
-- select @params = 'exec testjson "hello"'
-- select @params = "exec testjson 'hello'"
-- select @params = "exec testjson ""hello"""
select @params = 'exec testjson ''hello'''
exec (@params)
if exists(select * from sysobjects where name = 'testjson' and type='P')
drop procedure testjson
if exists(select * from sysobjects where name = 'testjson' and type='P')
drop procedure testjson
setuser 'dbo'
go
create procedure testjson(@p varchar(200))
as
begin
print @p
select distinct siteId from AlertWebsiteTb
end
go
declare @pa varchar(10)
select @pa = 'hello'
declare @params varchar(300)
select @params = 'exec testjson @pa'
exec (@params)
-- if the params is hard-coded
declare @params varchar(300)
-- select @params = 'exec testjson "hello"'
-- select @params = "exec testjson 'hello'"
-- select @params = "exec testjson ""hello"""
select @params = 'exec testjson ''hello'''
exec (@params)
if exists(select * from sysobjects where name = 'testjson' and type='P')
drop procedure testjson