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 |
|
hotshot_21
Yak Posting Veteran
97 Posts |
Posted - 2007-05-11 : 06:42:20
|
| I have a UDF which calculates three values.And i want to insert these values into a table.Which UDF shud i use?E.gCREATE Function CFS(var1,....)Returns floatAS BeginDeclare @Tot_Time_CFS float, @Avg_WLPD_CFS float, @Avg_OnDuty_Officer_CFS floatNow these 3 variables r calculate and i want to inser tthese three variable values into other table.how do i go about it, |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-05-11 : 06:48:45
|
| Well that only returns one value so you are a bit stuck.What are you actually trying to do? Best wuld be to not use a function but to code it in-line as that woud be much faster.==========================================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. |
 |
|
|
hotshot_21
Yak Posting Veteran
97 Posts |
Posted - 2007-05-11 : 06:52:10
|
| i am calculating 3 values which are being calculated in a function.and i want these 3 values to be stored in a row in a table.so i want to create a function for that .how do i go abt it. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-05-11 : 06:55:23
|
| Sounds like you want a table valued functioninsert tblselect t.val1, t.val2, t.val3from dbo.myfunc(....) t==========================================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. |
 |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-05-11 : 06:56:58
|
| like thiscreate function dbo.test12(@col1 int, @col2 int, @col3 int) returns @t table (c1 int, c2 int, c3 int)asbegin insert @t select @col1, @col1, @col1 returnEnddeclare @tt table(col1 int, col2 int, col3 int)Insert @ttselect * from dbo.test12(12,13,14)select * from @tt |
 |
|
|
|
|
|
|
|