在sql server 2005中的单引号包含单引号的写法

时间:2022-05-01 00:40:58
create proc Proc_GetOrderInfo_ByStatus( @Flag int)asdeclare @Msql varchar(1024)set @Msql = 'select * from vw_aspnet_OrderInfo where 1=1 'if(@Flag=1) set @Msql = @Msql + 'and IsConfirm = ''false'''else if(@Flag=2) set @Msql = @Msql + 'and IsConfirm = ''true'''else if(@Flag=3) set @Msql = @Msql + 'and IsConsignment = ''false'''else if(@Flag=4) set @Msql = @Msql + 'and IsConsignment = ''true'''else if(@Flag=5) set @Msql = @Msql + 'and IsPayment = ''false'''else if(@Flag=6) set @Msql = @Msql + 'and IsPayment = ''true'''else if(@Flag=7) set @Msql = @Msql + 'and IsPigeonhole = ''false'''else if(@Flag=8) set @Msql = @Msql + 'and IsPigeonhole = ''true'''exec(@Msql)
 
 
比如其中'and IsPigeonhole = true',实际上我需要的true是一个字符串,所以写成:'and IsPigeonhole = ''true'''