sql - Can a UDF return a list that can be used with an "IN" keyword? -
I Spiarsi with the SQL snippet:
- you more than Panlpyaut role To view the transaction type, the case statement is the case when it exists (select role-id from aspnet_UsersInRoles ur where ur.RoleID = 'DEDCD456-A25A-43C5-8125-A1D1223B19EC' and ur.UserID = s.aspnet_UserID) then (select IsNull (sum (amount), 0) from TransactionsLog payment Where payouts.StaffID = in s.ID and payouts.TransactionType (48, 49, 3, 16, 292, 293) and (payouts.OrderDate & gt; = dbo .Date (@date) and payouts.OrderDate & lt; = dbo.EndOfDay (@date)) and @shift = case @shift (0, 4, 4, 3), and then in the payouts.StaffID = s.ID and payouts.TransactionType (48, 49, 3) from the TransactionsLog payment. And (payouts.OrderDate & gt; = dbo.Date (@date) and payouts.OrderDate & lt; = dbo.EndOfDay (@date)) and @shift = case @shift when 0 then 0 als dbo.GetShiftByDate (payouts. OrderDate) END And it works fine. However, the total going to mix, 7 years before the database was originally structured, this is not returned query back to me because of some issues about Therefore, I use C #, which requires me I am My question UDF can return a list of Inton which can be used with the IN, so I only
(SELECT ISNULL (SUM (amount), 0) need to write, Pay with transaction, where payouts.StaffID = s.ID and dbo.PayoutTransactionsValidForStaff (s.ID) in payouts.TransactionType and (payouts.OrderDate> gt; = dbo.Date (@date) and payouts.OrderDate & lt; = Dbo.EndOfDay (@date)) and @shift = case @shift when 0 then 0 otherwise dbo.GetShiftByDate (payouts.OrderDate) end) Where PayoutTransactionsValidForStaff (s.ID ) will return the list of ints required to check? I thought it might be a table-value function, but I do not have time to do the test because I have to send this update. Just wondering if anyone knew from above their heads. Thanks!
Yes, you can create a table of values in SQL a table instead of a scalar Is the result You can create the result Sql in statement
. Function Dbo.Test () Returns @funcTable table (- The column obtained from Function ID is not the primary primary key) - Return some uncontrolled impressions BEGIN INSERT @funcTable values (1) INSERT @funcTable values Go (2) Return end - Test - insert insert 1,2,3 in a table var @SomeTable table (ID int) @SomeTable values (1) of the iNSERT (3) - @SomeTable in iNSERT (2) @SomeTable values @SomeTable values Choose where ID is in the result of UDF * Choose from some fast WHERE ID (SELECT I D FROM dbo.Test ())
Comments
Post a Comment