1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| CREATE PROCEDURE [351_13_Ajout_Ordres_Sans_Num]
AS
BEGIN
INSERT INTO [100_20_Ordres] ( [Depot], [Code_Article], [Groupe_Article], [Statut_Ordre], [Categorie_ordre], [Numero_ordre], [Ligne_ordre], [Sous_Ligne_Ordre], [Qte_Ordre_Article], [Code_Compose_Ou_fournisseur], [Date_Planif_Num], [Date_Planif_Date], [Message_Action], [Incrementer_Stock], [Numero_de_lot], [Code_Fournisseur] ) SELECT [000_20_Ordres_IMPORT].[Depot],
[000_20_Ordres_IMPORT].[Article],
[000_20_Ordres_IMPORT].[Gr_Article],
[000_20_Ordres_IMPORT].[Stt],
[000_20_Ordres_IMPORT].[Categorie_ordre],
numauto([Categorie_ordre],[Article],[Date_planif]) AS [Expr4],
[000_20_Ordres_IMPORT].[Ligne_ordre],
[000_20_Ordres_IMPORT].[Num_SousLigne],
[000_20_Ordres_IMPORT].[Qte_trans],
CASE WHEN [Categorie_ordre]='250' Or [Categorie_ordre]='251' THEN [Texte_reference] ELSE
CASE WHEN CHARINDEX(' ',[Texte_reference],1)>0 THEN LEFT([Texte_reference],CHARINDEX(' ',[Texte_reference],1)-1) ELSE [Texte_reference] END END AS [Expr2],
[000_20_Ordres_IMPORT].[Date_planif],
CONVERT(DATETIME,CASE WHEN [000_20_Ordres_IMPORT].[Date_planif]=0 THEN '' ELSE CONVERT(DATETIME,RIGHT([000_20_Ordres_IMPORT].[Date_planif],2) + '/' + LEFT(RIGHT([000_20_Ordres_IMPORT].[Date_planif],4),2) + '/' + LEFT([000_20_Ordres_IMPORT].[Date_planif],4)) END) AS [Expr3],
[000_20_Ordres_IMPORT].[MA],
[000_20_Ordres_IMPORT].[MaJ_Dispo_article],
[000_20_Ordres_IMPORT].[Numero_de_lot],
'Aucun' AS [Expr1]
FROM [000_20_Ordres_IMPORT]
WHERE ((([000_20_Ordres_IMPORT].[Categorie_ordre])='960' Or ([000_20_Ordres_IMPORT].[Categorie_ordre])='020'))
End |
Partager