Voilà un petit code fort pratique en ASP pour copier une table vide avec le nom de votre choix (nom_table). La table VIDE correspond à la table que vous souhaitez copier, bien entendu vous aurez pris soin de la créer avec les champs de votre choix sans données.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <%@ Language=VBScript %>  <%  ' === création table M si inexistante ============================================= Set ConBDD     = CreateObject("ADODB.Connection") sDB                  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\www\chemin_physique_vers_votre_base"  conBDD.Open sDB dim rs2:set rs2=createobject("ADODB.recordset") nom_table = DatePart("m",Date()) &"_"& DatePart("yyyy",Date()) flag_er=True rs2.open conBDD.OpenSchema (20) do while not rs2.eof             if rs2(3)= "TABLE" then                         if rs2(2)= nom_table then                         flag_er=False:   exit do                         end if             end if  rs2.movenext loop rs2.close if flag_er then                 conBDD.execute "SELECT * INTO " & nom_table & " from VIDE;"           ' table vide avec les champs prédéfinis             rs2.open "select * from STATS order by id_stat", conBDD,1,2             rs2.addnew             rs2("stat_table") = nom_table             rs2.update             rs2.close end if ' fermeture connexion set rs2=nothing: set rs=nothing conBDD.Close '---- Détermine si l'année est bisextiles ou pas ---- Function BisexYear(WhichYear)     If WhichYear/4=Int(WhichYear/4) Then         BisexYear=True     Else         BisexYear=False     End If End Function '---- Le nombre de jours dans un mois ---- Function xDaysIn(WhichDate)     Dim xdays     xDays=Array("","31","","31","30","31","30","31","31","30","31","30","31")     If Month(WhichDate)=2 Then         If BisexYear(Year(WhichDate))=True Then             xDaysIn=29         Else             xDaysIn=28         End If           Else         xDaysIn=xDays(Month(WhichDate))     End If End Function    %> | 
PS : Vous noterez deux petites fonctions capables de déterminer si l’année est bissextile et le nombre de jours dans un mois.
Please follow and like us:
 
							
