我正在尝试执行此选择:
RewriteRule ^urunler/([0-9a-zA-Z-_]+)/([0-9]+)/?$ urunler.php?kategori_id=$1&page=$2 [L,QSA]
使用此程序:
SELECT a.*,b.descricao as dscstatus,c.nome as cliente
FROM pedidos a with(nolock),
pedidos_status b with(nolock),
cadastro c with(nolock)
WHERE a.status <> '' and
a.status=b.status and
a.id_doc = c.id_doc
and c.nome like 'CAR%'
and data_inclusao BETWEEN '20160101' AND '20160202'
和这个命令:
ALTER PROCEDURE LISTA_PEDIDOS
@Sdatainicio varchar(100),
@Sdatafim varchar(100),
@chaveBusca varchar(100),
@TipoBusca varchar(100)
AS
DECLARE @SQL VARCHAR(8000) = ''
SET @SQL += 'SELECT a.*,b.descricao as dscstatus,c.nome as cliente '
SET @SQL += ' FROM pedidos a with(nolock), '
SET @SQL += ' pedidos_status b with(nolock), '
SET @SQL += ' cadastro c with(nolock) '
SET @SQL += ' WHERE '
SET @SQL += ' a.status <> '''' and '
SET @SQL += ' a.status=b.status and '
SET @SQL += ' a.id_doc = c.id_doc '
IF isnull(@chaveBusca,'')<>''
BEGIN
IF isnull(@TipoBusca,'') = 'PEDIDO'
SET @SQL += ' and a.numped= '''+@chaveBusca+''''
IF isnull(@TipoBusca,'') = 'CLIENTE'
SET @SQL += ' and c.nome like '''+@chaveBusca+'%'''
END
IF not (isnull(@chavebusca,'')<>'' and isnull(@TipoBusca,'') = 'PEDIDO')
SET @SQL += ' and data_inclusao BETWEEN '''+@Sdatainicio+''' AND '''+@Sdatafim+''''
EXECUTE @SQL
但它给了我这个错误信息:
Msg 203,Level 16,State 2,Procedure LISTA_PEDIDOS,第39行
名称'SELECT a。*,b.descricao as dscstatus,c.nome as cliente FROM pedidos a with(nolock),pedidos_status b with(nolock),cadastro c with(nolock)WHERE a.status&lt;&gt; ; ''和a.status = b.status和a.id_doc = c.id_doc和c.nome如'CAR%'和data_inclusao BETWEEN'20160101'''20160202''不是有效的标识符。
是因为我在程序结束时使用EXECUTE @SQL吗?我是新来的btw。