When knocking on the computer room charging system, when encountered adding time always through the VB end of the call to add to the current time to SQL Server, and sometimes because of the addition of time format is not unified to cause some small problems, now only know that the original is their own ignorance, SQL Server can be automatically added through time.
Now I simply introduce these two tips for you to automatically add time to the host self growth. 1, automatically add time
A, method one
CREATE table Text
(
ID int primary KEY,
newdate datetime default (GetDate ())
B, Method two
Add a field to set the data type to datetime, modify the default value, or bind to GETDATE (), as shown in
2, the primary key from the growth
CREATE TABLE test_create_tab2 (
ID INT IDENTITY (1, 1) PRIMARY KEY,
val VARCHAR (10);
where identity (1, 1) indicates an initial value of 1, with an increase of 1 each time
At this point, only the primary key can be added when the database is inserted through the code, and no properties can be modified for this purpose.
Then, if you forget to add your own growing primary key when you add a table, you can modify the SQL Server primary key to grow automatically.
In fact, it is also simple, you can delete the original primary key and then add it again
ALTER TABLE name DROP column name ALTER TABLE
name ADD column name [int] IDENTITY (1,1) not NULL;
In fact, there are many useful functions in SQL Server, such as triggers, stored procedures, and so on, can greatly reduce our coding and coding difficulties, there are many unknown areas waiting for us to explore.