向大虾提一个关于sql的问题
EXECusp_InsertPosition,'研发部nvarchar(50),产品研发nvarchar(50)'usp_Insert是存储过程,Position是表名,...
EXEC usp_Insert Position,'研发部 nvarchar(50),产品研发 nvarchar(50)'
usp_Insert是存储过程,Position是表名,研发部 nvarchar(50),产品研发 nvarchar(50)'是我要插入的内容,但是出错了,请教大虾帮忙
ALTER PROCEDURE [dbo].[usp_Insert]
(
@TableCondition nvarchar(50),
@ValueCondition nvarchar(max)=null
)
AS
DECLARE @SQL nvarchar(max)
SET @SQL = 'INSERT INTO ['+ @TableCondition + ']'
IF @ValueCondition IS NOT NULL AND LEN(@ValueCondition)>0
BEGIN
SET @SQL = @SQL + 'VALUES ('+@ValueCondition+')'
END
EXEC SP_EXECUTESQL @SQL
SELECT @@IDENTITY
RETURN
我觉得这个存储过程语句是有问题的,正在百度提问解决,恳请大虾帮忙看看,这个存储过程是通用存储过程,另外在C#语句中的代码是
string sql = "usp_Insert";
string valueCondition = string.Format(@"DepartmentName ='{0}',DepartmentDescription ='{1}'", department.DepartmentName, department.DepartmentDescription);
SqlParameter[] paras =
{
new SqlParameter("@TableCondition","Department"),
new SqlParameter("@ValueCondition",valueCondition)
};
ExecuteNonQuery语句 展开
usp_Insert是存储过程,Position是表名,研发部 nvarchar(50),产品研发 nvarchar(50)'是我要插入的内容,但是出错了,请教大虾帮忙
ALTER PROCEDURE [dbo].[usp_Insert]
(
@TableCondition nvarchar(50),
@ValueCondition nvarchar(max)=null
)
AS
DECLARE @SQL nvarchar(max)
SET @SQL = 'INSERT INTO ['+ @TableCondition + ']'
IF @ValueCondition IS NOT NULL AND LEN(@ValueCondition)>0
BEGIN
SET @SQL = @SQL + 'VALUES ('+@ValueCondition+')'
END
EXEC SP_EXECUTESQL @SQL
SELECT @@IDENTITY
RETURN
我觉得这个存储过程语句是有问题的,正在百度提问解决,恳请大虾帮忙看看,这个存储过程是通用存储过程,另外在C#语句中的代码是
string sql = "usp_Insert";
string valueCondition = string.Format(@"DepartmentName ='{0}',DepartmentDescription ='{1}'", department.DepartmentName, department.DepartmentDescription);
SqlParameter[] paras =
{
new SqlParameter("@TableCondition","Department"),
new SqlParameter("@ValueCondition",valueCondition)
};
ExecuteNonQuery语句 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询