日期:2014-05-18  浏览次数:20458 次

sql 存储过程,报错...
SQL code



SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER proc [dbo].[Checking](
@tableName varchar(50),--表名
@SelName varchar(50)--条件
)
as
begin
declare @sql varchar(50)
set @sql='select count(*) from '+@tableName+' where username='''+@SelName+''''
             
print @sql
exec @sql
end
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO




SQL code

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER proc [dbo].[Checking](
@tableName varchar(50),--表名
@SelName varchar(50)--条件
)
as
begin
declare @sql varchar(50)
set @sql='select count(*) from '+@tableName+' where username='''+@SelName+''''
             
print @sql
exec @sql
end
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO




------解决方案--------------------
探讨

这是表
SQL code

USE [CA]
GO
/****** 对象: Table [dbo].[AccountInfo] 脚本日期: 03/07/2012 15:12:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Acc……