Store Procedure Sample: 1. Calling method DECLARE @sMyValue varchar(300) execute sTest1 '4', @sMyValue OUTPUT PRINT '@sMyValue=' + @sMyValue select @sMyValue 2. Procedure Content CREATE PROCEDURE STEST1 @spInput varchar(40), @spOutput varchar(250) OUTPUT AS -- sSample1 -- Date Author Comment -- ---------- ------- ------------------------------------------ -- 2007.01.17 Honda Create --USE Test1 --GO DECLARE @sF01 varchar(40) DECLARE @sF02 varchar(20) DECLARE @sOutput varchar(250) DECLARE @iLoop1 int DECLARE @sLine varchar(250) select @sOutput = '' select @sLine = '' select @iLoop1 = 1 DECLARE cur1 CURSOR FOR SELECT F01, F02 FROM T01 WHERE F01 = @spInput ORDER BY F02 OPEN cur1 WHILE (@iLoop1 = 1) BEGIN FETCH NEXT FROM cur1 INTO @sF01, @sF02 IF (NOT (@@FETCH_STATUS = 0)) BEGIN BREAK END set @sLine = rtrim(@sLine) + rtrim(@sF02) + ',' END CLOSE cur1 DEALLOCATE cur1 if (len(@sLine)>0) BEGIN set @sOutput = left(@sLine, len(@sLine)-1) END PRINT 'sOutput=' + @sOutput set @spOutput = @sOutput GO 3. Test Table T01 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T01]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[T01] GO CREATE TABLE [dbo].[T01] ( [F01] [char] (7) COLLATE Chinese_Taiwan_Stroke_CI_AS NOT NULL , [F02] [char] (9) COLLATE Chinese_Taiwan_Stroke_CI_AS NOT NULL ) ON [PRIMARY] GO