This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
bw:sql_server_tips [2019/05/01 11:07] runger created |
bw:sql_server_tips [2019/06/04 15:18] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Store Procedure for SAP Business One Special Pricing ===== | + | ===== Stored |
| This procedure can be used as the data source in a Versago look-up report to find the lowest price for a business partner (typically a customer) based on price list, special pricing, date sensitive pricing, and quantity break pricing. | This procedure can be used as the data source in a Versago look-up report to find the lowest price for a business partner (typically a customer) based on price list, special pricing, date sensitive pricing, and quantity break pricing. | ||
| Line 54: | Line 54: | ||
| AND a.Amount <= @qty | AND a.Amount <= @qty | ||
| </ | </ | ||
| + | |||
| + | ===== Create a DateTime Value From Two Separate Columns ===== | ||
| + | In many places, SAP Business One (and other applications) store the date and time in two separate columns. | ||
| + | |||
| + | <code sql> | ||
| + | cast( | ||
| + | cast(datepart(year, | ||
| + | + ' | ||
| + | + right(' | ||
| + | + ' | ||
| + | + right(' | ||
| + | + ' ' | ||
| + | + left(right(' | ||
| + | + ':' | ||
| + | + left(right(' | ||
| + | as datetime) as [CombinedDateTime] | ||
| + | </ | ||
| + | |||
| + | ===== Use DISTINCT in a SQL Select Statement ===== | ||
| + | If the DISTINCT operator is needed, it must be done within a sub-query. | ||
| + | |||
| + | <code sql> | ||
| + | SELECT DISTINCT | ||
| + | t0.Name | ||
| + | from TableName t0 | ||
| + | </ | ||
| + | |||
| + | However, if this statement is used as a sub-query, it can be used in Versago. | ||
| + | |||
| + | <code sql> | ||
| + | SELECT a0.* from | ||
| + | ( | ||
| + | SELECT DISTINCT | ||
| + | t0.Name | ||
| + | from TableName t0 | ||
| + | ) a0 | ||
| + | </ | ||
| + | |||
| + | In this case, " | ||