Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pipi
Starting Member
18 Posts |
Posted - 2005-05-20 : 03:49:51
|
HI!!! I HAVE A STORED PROCEDURE which return a double value and i want to execute it in a select statement.for each row from one table.e.gset dateformat dmy;declare @out1 FLOATdeclare @apo datetimedeclare @eos datetimeSELECT @apo=cast('01/01/2005' as datetime)SELECT @eos=cast('31/12/2005' as datetime)select ktm_loga_typo,ktm_loga_kodi,ktm_loga_dik1,@out1=exec GetPelaLogaMesoYpolVale ktm_loga_dik1,ktm_loga_kodi,@apo,@eos,@mesoypol=@out1 OUTPUT from ktmwhat I m I doing wrong?please, can anyone help me with this one?/deppi |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-05-20 : 04:07:38
|
| You can't do that.Create a function instead would be the best bet or populate a temp table and use the sp to update it.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
raclede
Posting Yak Master
180 Posts |
Posted - 2005-05-20 : 04:17:32
|
| use function:select ktm_loga_typo,ktm_loga_kodi,ktm_loga_dik1,dbo.GetPelaLogaMesoYpolVale(ktm_loga_dik1,ktm_loga_kodi) from ktmCREATE FUNCTION dbo.GetPelaLogaMesoYpolVale(@inputfield1 datatype,@inputfield2 datatype,) RETURNS datatype AS BEGIN DECLARE @retVal Datatype{to do SET @retVal = ......}RETURN @RetValENDCursors are for those who doesn't know how to use SQL K.I.S.S. - Keep it simple stupidraclede™ |
 |
|
|
pipi
Starting Member
18 Posts |
Posted - 2005-05-20 : 05:12:40
|
| I FIXED THE STORED PROCEDURE AS A FUNCTION BUT I USED TEMPORARY TABLES SO,I GET THIS ERROR MESSAGE"CANNOT ACCES TEMP TABLES FROM WITHIN A FUNCTION.??? |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-05-20 : 05:22:29
|
| Means what it says.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
raclede
Posting Yak Master
180 Posts |
Posted - 2005-05-20 : 05:22:41
|
| you cannot use temp tables in a function, use it on the stored procedure..Cursors are for those who doesn't know how to use SQL K.I.S.S. - Keep it simple stupidraclede™ |
 |
|
|
pipi
Starting Member
18 Posts |
Posted - 2005-05-20 : 06:14:17
|
| thanks.I tried this with cursor.I use cursors for first time,but i still have a problem.the execution of the stored procedure is not workinge.gdECLARE @typo varchar(20)declare @apo datetimedeclare @eos datetimeDECLARE @meso moneySELECT @apo=CONVERT(datetime,'01/01/2005')--SELECT @eos=cast('31/12/2005' as datetime)SELECT @eos=CONVERT(datetime,'31/12/2005')DECLARE c2 CURSOR FORselect ktm_loga_kodi,ktm_loga_dik1from ktmOPEN c2FETCH NEXT FROM c2INTO @loga,@pelaWHILE @@FETCH_STATUS = 0BEGIN PRINT @loga print @pela EXEC GetPelaLogaMesoYpolVale @pela,@loga,@apo,@eos,@mesoypol=@meso OUTPUT FETCH NEXT FROM c2 INTO @loga,@pelaENDCLOSE c2 DEALLOCATE c2can you help me.i want for reach row to return 3 columnspela,loga,mesoypol |
 |
|
|
mpetanovitch
Yak Posting Veteran
52 Posts |
Posted - 2005-05-20 : 20:34:50
|
| Turn you temp table into a declare table and you will be able to use a function.Mike Petanovitch |
 |
|
|
|
|
|
|
|