I'm trying to schedule a long T-SQL script. However, the script gets cut off when pasted into the text box. I googled the problem and there is a 3200 character limit.
What do you recommend I do to solve this? Create a stored procedure and run that as a scheduled job? Is there a better option? If it helps, here is the script.
INSERT INTO CheltonCustomizations..SOBacklogAudits (SoNo,
SoRev,
SysItemNo,
UserItemNo,
Release,
OrderDate,
DueDate,
PartNo,
PartRev,
OrderQty,
ShippedQty,
ShippedNotInvoicedQty,
InvoicedQty,
ProdCl,
[Group],
NetAmount,
SorelsIdentityColumn,
BacklogDate)
SELECT SOR.fsono,
SOM.fsorev,
SOR.fenumber,
SOR.finumber,
SOR.frelease,
SOM.[forderdate],
SOR.fduedate,
SOR.fpartno,
SOR.fpartrev,
SOR.forderqty,
SOR.fshipbook + SOR.fshipbuy + SOR.fshipmake,
COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY (
SOR.fsono + SOR.finumber + SOR.frelease),
0),
SOR.finvqty,
SOI.fprodcl,
SOI.fgroup,
(SOR.forderqty - SOR.finvqty
- COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY (
SOR.fsono + SOR.finumber + SOR.frelease),
0))
* SOR.funetprice,
SOR.identity_column,
getdate ()
--CONVERT (DATETIME, '02/09/2009')
FROM SORELS SOR
INNER JOIN SOITEM SOI
ON SOR.finvqty <
SOR.forderqty
- COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY (
SOI.FSONO + SOR.finumber + SOR.frelease),
0)
- 0
AND SOR.finvqty <
SOR.forderqty
- COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY (
SOR.fsono + SOI.FINUMBER + SOR.frelease),
0)
- 0
AND SOR.FSONO = COALESCE (SOI.FSONO, SOI.FSONO)
AND SOR.FINUMBER = SOI.FINUMBER
INNER JOIN SOMAST SOM
ON SOR.finvqty <
SOR.forderqty
- COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY (
SOM.FSONO + SOR.finumber + SOR.frelease),
0)
- 0
AND SOR.FSONO = COALESCE (SOM.FSONO, SOM.FSONO)
AND SOI.FSONO = SOM.FSONO
WHERE SOM.FSTATUS = 'OPEN' AND FMASTERREL = COALESCE (0, 0)
AND SOM.forderdate >=
CONVERT (DATETIME, '01/01/2002')
AND SOR.forderqty >
0 + SOR.finvqty
+ COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY(SOR.fsono
+ SOR.finumber
+ SOR.frelease),
0)
AND SOR.finvqty <
SOR.forderqty
- COALESCE (
DBO.GETSHIPPEDNOTINVOICEDQTY(SOR.fsono
+ SOR.finumber
+ SOR.frelease),
0)