reza_edu
شنبه 17 اردیبهشت 1390, 14:25 عصر
سلام من یه تابع نوشتم که تو یه قسمت از اون باید یک رشته به رشته دیگه اضافه بشه اما جای تعجب اینجا هست که همین دستور تو خارج از این تابع به درستی عمل میکنه اما داخل تابع عمل نمیکنه من این مشکل رو تو msdn مطرح کردم نمیدونم زبانم ضعیف بود که جواب ندادن یا اینکه تابحال به این مشکل برنخورده بودن اگه ممکنه شما راهنمائی کنید باتشکر.
لینک سوال http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/841fe082-ce51-461a- (http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/841fe082-ce51-461a-bec7-671f80c8c8b3)
bec7-671f80c8c8b3 (http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/841fe082-ce51-461a-bec7-671f80c8c8b3)
اینم تابع :
USE [ExtentScience]
GO
/****** Object: UserDefinedFunction [dbo].[SumInfo_CognitionComputer] Script Date: 04/08/2011 18:17:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[SumInfo_CognitionComputer]
(
@CodeRoot NVARCHAR(50)
)
RETURNS NVARCHAR(Max)
AS
BEGIN
DECLARE @StrResult NVARCHAR(Max),@Str NVARCHAR(Max),@CountCodeRoot INT ;
SELECT @CountCodeRoot = COUNT(@CodeRoot)-1 FROM View_CognitionComputer ;
WHILE(@CountCodeRoot>0)
BEGIN
SELECT @Str = V1.ShowID_LevelCognitionComputer + ' - ' + V1.ShowID_TributaryComputer+ ' - ' + V1.Comment + ' / ' FROM View_CognitionComputer V1
WHERE CodeRoot = @CodeRoot AND @CountCodeRoot = ( SELECT COUNT(*) FROM View_CognitionComputer V2
WHERE V2.CodeRoot = V1.CodeRoot AND V2.ID_LevelCognitionComputer <= V1.ID_LevelCognitionComputer ) ;
SET @CountCodeRoot = (@CountCodeRoot - 1)
SELECT @StrResult = @Str + @StrResult
END
RETURN @StrResult;
END
مشکل تو این دستور هست :
SELECT @StrResult = @Str + @StrResult
لینک سوال http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/841fe082-ce51-461a- (http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/841fe082-ce51-461a-bec7-671f80c8c8b3)
bec7-671f80c8c8b3 (http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/841fe082-ce51-461a-bec7-671f80c8c8b3)
اینم تابع :
USE [ExtentScience]
GO
/****** Object: UserDefinedFunction [dbo].[SumInfo_CognitionComputer] Script Date: 04/08/2011 18:17:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[SumInfo_CognitionComputer]
(
@CodeRoot NVARCHAR(50)
)
RETURNS NVARCHAR(Max)
AS
BEGIN
DECLARE @StrResult NVARCHAR(Max),@Str NVARCHAR(Max),@CountCodeRoot INT ;
SELECT @CountCodeRoot = COUNT(@CodeRoot)-1 FROM View_CognitionComputer ;
WHILE(@CountCodeRoot>0)
BEGIN
SELECT @Str = V1.ShowID_LevelCognitionComputer + ' - ' + V1.ShowID_TributaryComputer+ ' - ' + V1.Comment + ' / ' FROM View_CognitionComputer V1
WHERE CodeRoot = @CodeRoot AND @CountCodeRoot = ( SELECT COUNT(*) FROM View_CognitionComputer V2
WHERE V2.CodeRoot = V1.CodeRoot AND V2.ID_LevelCognitionComputer <= V1.ID_LevelCognitionComputer ) ;
SET @CountCodeRoot = (@CountCodeRoot - 1)
SELECT @StrResult = @Str + @StrResult
END
RETURN @StrResult;
END
مشکل تو این دستور هست :
SELECT @StrResult = @Str + @StrResult