TSQL,sp_executesql 我这个SQL 总报错 过程需要类型为 'ntext/nchar/nvarchar' 的参数 '@parameters

declare @InsertSQL nvarchar(MAX);
    set @InsertSQL = N'Insert Into dbo.['+@tableName+N'](ParentID,SourceID,NickName,Content,IP,City,BeFiltered,[Disable])
    values (@ParentID,@SourceID,@NickName,@Content,@IP,@City,@BeFiltered,@Disable);select @InsertedID = SCOPE_IDENTITY();';
    
    exec sp_executesql @InsertSQL,
    '@ParentID int,@SourceID int,@NickName nvarchar(20),@Content nvarchar(300),@IP nvarchar(30),@City nvarchar(30),@BeFiltered bit,@Disable bit,@InsertedID int output',
    @ParentID,
    @SourceID,
    @NickName,
    @Content,
    @IP,
    @City,
    @BeFiltered,
    @Disable,
    @InsertedID output;
烙印99
浏览 441回答 2
2回答

慕姐8265434

declare @InsertSQL nvarchar(MAX); set @InsertSQL = N'Insert Into dbo.['+@tableName+N'](ParentID,SourceID,NickName,Content,IP,City,BeFiltered,[Disable]) values (@ParentID,@SourceID,@NickName,@Content,@IP,@City,@BeFiltered,@Disable);select @InsertedID = SCOPE_IDENTITY();'; exec sp_executesql @InsertSQL, N'@ParentID int,@SourceID int,@NickName nvarchar(20),@Content nvarchar(300),@IP nvarchar(30),@City nvarchar(30),@BeFiltered bit,@Disable bit,@InsertedID int output', @ParentID, @SourceID, @NickName, @Content, @IP, @City, @BeFiltered, @Disable, @InsertedID output; 已经修正错误

猛跑小猪

你在创建过程的时候并没有给他输入参数,为什么你在执行的时候会给它输入参数呢?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

SQL Server