String-uri in SQLServer2000
Am asa o procedura mica:CREATE PROCEDURE dbo.sp_get_balance ASset nocount onDECLARE @agentid int,@sold money,@balanta moneyDECLARE @SQLString varchar(2000),@stragentid varchar(40)CREATE TABLE #tempTable (tempvar MONEY)SET @balanta=0--calculez banii cashDECLARE CasaCursor CURSOR FOR SELECT nAgent_ID,cSoldCD FROM tblAgent WHERE bActiv=1 AND (bCasa=1 OR bBanc=1)OPEN CasaCursorFETCH NEXT FROM CasaCursor into @agentid,@soldwhile @@fetch_status=0begin SET @stragentid=CONVERT(NVARCHAR(40),@agentid) SET @SQLString='SELECT ISNULL(SUM(nSuma),0)+'+CONVERT(varchar(40),@sold)+' AS Valoare '+ 'FROM((SELECT nSuma FROM dbo.tblDoc_Bani '+ 'WHERE (nParent_ID = '+@stragentid+') AND (nDocument_ID=25 OR nDocument_ID=14 OR '+ 'nDocument_ID=23 OR nDocument_ID=27 OR nDocument_ID=8 OR nDocument_ID=50)'+ ') UNION ALL '+ '(SELECT -nSuma FROM dbo.tblDoc_Bani '+ 'WHERE (nParent_ID='+@stragentid+' ) AND '+ '(nDocument_ID=24 OR nDocument_ID=9 OR nDocument_ID=15 OR nDocument_ID=26 OR '+ 'nDocument_ID=7 OR nDocument_ID=49) '+ ') UNION ALL '+ '(SELECT nSuma FROM dbo.tblDoc_Bani '+ 'WHERE (nBeneficiar_ID = '+@stragentid+') AND (nDocument_ID=5) '+ ')UNION ALL '+ '(SELECT -nSuma FROM dbo.tblDoc_Bani '+ 'WHERE (nPlatitor_ID = '+@stragentid+' ) AND (nDocument_ID=5) '+ ')) TBL' DELETE #tempTableSELECT @SQLString --IACA ICI II BUBA: EL IMI SCOATE DOAR 256 de simboluri --INSERT INTO #tempTable EXECUTE sp_executesql @SQLString --SET @balanta=@balanta+(SELECT TOP 1 tempvar FROM #tempTable) FETCH NEXT FROM CasaCursor into @agentid,@soldendCLOSE CasaCursorDEALLOCATE CasaCursorSELECT @balanta GOProcedura imi returneaza doar 256 simboluri (mai putin de jumate de continutul lui @SQLString).De ce asa se intimpla?