By David Crowther
Question:
How can I automatically insert the date into records in my SQL table?
Answer:
You may have a GIS Layer e.g. Planning Applications that are stored as a Table in a SQL database. Each time a new record (Planning App) is inserted into that table you would like today’s date adding into a Date Created field.
In our example we have a Planning App layer in our webGIS - MapThat.
Before we insert a new record into the Planning Apps layer, we will edit the SCHEMA of our SQL Table to. To do this, select the table via SSMS > right click and choose DESIGN.
- Add a Date_Created Field – Type Date.
- Using a Default Value – of Todays Date by using the text – getdate()
Close and Save the changes to the Table Schema.
Now using MapThat (or QGIS), when a user adds a new record into the layer (Planning App)…
….. once the new record has been inserted, the new field Date_Created will automatically be updated with today’s date by using the default value of getdate().
Comments (0 comments)