FExplanation varchar (255), the default (' '))
Go
Insert into # TmpBillCheckList (FExplanation)
The select a.F Explanation
The from t_rp_newReceiveBill a
Inner join t_rp_arbillofsh c on a.F BillID=c.F BillID
The join t_rp_contact b on a.F BillID=b. BillID
Left the join t_currency cur on a.F CurrencyID=cur. FCurrencyID
Left the join t_item I on a.F Customer=i.F ItemID
Left the join t_item ii on a.F Department=ii. FItemID
Left the join t_item iii on a.F Employee=iii. FItemID
Left the join t_user s on a.F PreParer=s. UserID
Left the join t_user t on a.F Checker=t.F UserID
Left the join t_settle x1 on a.F Settle=x1. FItemID
Left the join t_rp_systemenum x2 on a.F BillType=x2. FItemID
Left the join (select v1. FVoucherID, v1 FNumber, v2, Fname Fname from t_voucher v1
Inner join t_vouchergroup v2 on v1. FGroupid=v2. FGroupid) v on b. VoucherID=v. VoucherID
Where 1=1 and (c.FID_SRC=https://bbs.csdn.net/topics/0 or c.F ClassID_SRC not in (1000000100002100003100004100005100014100021100022100500100501100502100503100520100521100140100016100018100511100510)) and a.F Rp=1 and a.F Pre in (0, 1)
And b. Type not in (8, 9) and a.F CheckStatus<> 1
And a.F ItemClassID in (1)
And (b. Status & amp; 1)=1
And (b. Status & amp; 16)=0
And i.F Number>
='01. BTC125'And i.F Number
='01. BTC125'And a.F CurrencyID=1000
Go
Drop table # TmpBillCheckList
SQL code as
Problem is currently executing as title wrong,
If you remove a line left join does not affect the result of the query data, to perform is not an error
CodePudding user response:
According to the following check, you see what the actual length of more than 255 of those data?- 1.
The CREATE TABLE # TmpBillCheckList (FExplanation VARCHAR (MAX) DEFAULT (' '))
2
-INSERT INTO # TmpBillCheckList (FExplanation)
The SELECT a.F Explanation
The FROM t_rp_newReceiveBill a
INNER JOIN t_rp_arbillofsh c
ON a.F BillID=c.F BillID
The JOIN t_rp_contact b
ON a.F BillID=b. BillID
LEFT the JOIN t_currency cur
ON a.F CurrencyID=cur. FCurrencyID
LEFT the JOIN t_item I
ON a.F Customer=i.F ItemID
LEFT the JOIN t_item ii
Ii. FItemID ON a.F Department=
LEFT the JOIN t_item iii
ON a.F Employee=iii. FItemID
LEFT the JOIN t_user s
ON a.F PreParer=s. UserID
LEFT the JOIN t_user t
ON a.F Checker=t.F UserID
LEFT the JOIN t_settle x1
ON a.F Settle=x1. FItemID
LEFT the JOIN t_rp_systemenum x2
ON a.F BillType=x2. FItemID
LEFT the JOIN (
The SELECT v1 FVoucherID,
V1. FNumber,
V2. Fname Fname
The FROM t_voucher v1
INNER JOIN t_vouchergroup v2
ON v1. FGroupid=v2. FGroupid
) v
ON b. VoucherID=v. VoucherID
WHERE 1=1
AND (
C.F ID_SRC=https://bbs.csdn.net/topics/0
The OR c.F ClassID_SRC NOT IN (1000000, 1000002, 1000003, 1000004,
1000005, 1000014, 1000021, 1000022,
1000500, 1000501, 1000502, 1000503,
1000520, 1000521, 1007140, 1000016,
1000018, 1000511, 1000510)
)
AND a.F Rp=1
AND a.F Pre IN (0, 1)
AND b. Type NOT IN (8, 9)
AND a.F CheckStatus & lt;> 1
AND a.F ItemClassID IN (1)
AND (b. Status & amp; 1)=1
AND (b. Status & amp; 16)=0
AND i.F Number & gt;
='01. BTC125'AND i.F Number & lt;
='01. BTC125'AND a.F CurrencyID=1000
3
-The SELECT len (FExplanation) AS theLen, FExplanation
The FROM # TmpBillCheckList WHERE len (FExplanation) & gt; 255
The ORDER BY len (FExplanation) DESC
4
-DROP TABLE # TmpBillCheckList