34,590
社区成员
发帖
与我相关
我的任务
分享
select a from a_table where ad_id = 0010101
这时候a是唯一的字符串。
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[aaaaproc]
@IndexValue int,
@Combostring nvarchar (256) output,
@NLen INT
AS
BEGIN
declare @sql nvarchar(4000)
SET @sql ='SELECT @Combostring = row_value
FROM combobox_temp_table
WHERE index_value = '+ltrim(@IndexValue )
exec sp_executesql @sql ,N'@Combostring int output',@Combostring output
--这里写错了,@Combostring 不用该是int类型
select @sql as '@sql'
select @Combostring as '@Combostring'
END
--sql server执行如下
USE [aaaaaaaa]
GO
DECLARE @IndexValue int,
@Combostring varchar (256) ,
@NLen INT
EXEC [dbo].[aaaaproc]
@IndexValue = 1,@Combostring = @Combostring output,@NLen = 0
SELECT @Combostring as '@Combostring'
GO
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[aaaaproc]
@IndexValue int,
@Combostring nvarchar (256) output,
@NLen INT
AS
BEGIN
declare @sql nvarchar(4000)
SET @sql ='SELECT @Combostring = row_value
FROM combobox_temp_table
WHERE index_value = '+ltrim(@IndexValue )
exec sp_executesql @sql ,N'@Combostring int output',@Combostring output
select @sql as '@sql'
select @Combostring as '@Combostring'
END
--sql server执行如下
USE [aaaaaaaa]
GO
DECLARE @IndexValue int,
@Combostring varchar (256) ,
@NLen INT
EXEC [dbo].[aaaaproc]
@IndexValue = 1,@Combostring = @Combostring output,@NLen = 0
SELECT @Combostring as '@Combostring'
GO