SQL Server learning and growth path, each technology learning process is worth to be memorable, and now Baidu on the sqlser on a lot of information, but are too miscellaneous, I hope to share a little easy to understand the dry, with everyone to improve learning.
I. Establishment of the table
1, create the table stu_paper (various common types of fields are available)
IF not EXISTS (SELECT * from SYSOBJECTS WHERE NAME ='Stu_paper'and TYPE ='U') BEGIN--Questionnaire CREATE Table Stu_paper (p_idintIDENTITY (1,1) primary key not NULL, TITLE VARCHAR ( $)default "'Not NULL, start_time datetimedefaultgetdate () not NULL, Show_contentint default 0Not NULL, user_num bigintdefault 0Not NULL, FLAGint default 0Not NULL, NTAG1 numeric (Ten,4),) END GO
2. CREATE TABLE Stu
IF not EXISTS (SELECT * from SYSOBJECTS WHERE NAME ='Stu'and TYPE ='U') BEGIN--Questionnaire CREATE Table Stu (p_idintIDENTITY (1,1) primary key not NULL, TITLE VARCHAR ( $)default "'Not NULL, start_time datetimedefaultgetdate () not NULL, Show_contentint default 0Not NULL, user_num bigintdefault 0Not NULL, FLAGint default 0Not NULL, NTAG1 numeric (Ten,4),) END GO
Ii. Add fields for table Stu_paper
1 int default 0 NULL ; 2 ALTER TABLE Dbo.stu_paper add name VARCHAR ($default'null;
Third, modify the field in table stu_paper the length of name is varchar (256)
1 ALTER TABLE Stu_paper ALTER column name varchar (n);
Iv. Stored Procedures
1. Create a stored procedure to synchronize the data in the table Stu_paper to the table Stu
1 CREATE PROC [DBO]. [Pro_stupaper] 2 as 3 IF EXISTS (SELECT COUNT (*) from Dbo.stu_paper)4BEGIN5 DELETE from Dbo.stu_paper; 6 INSERT into Dbo.stu (TITLE,START_TIME,SHOW_CONTENT,USER_NUM,FLAG,NTAG1)7 SELECT title,start_time,show_content,user_num,flag,ntag1 from Dbo.stu_paper; 8 END 9 GO
2. Execute Stored Procedure
1 EXEC Dbo.pro_stupaper 2 GO
V. SQL Server timed Tasks
1. Create timed tasks (i.e. jobs)
Reference URL: https://jingyan.baidu.com/article/b907e62790e89846e7891cc4.html?qq-pf-to=pcqq.c2c
2. Check the Scheduled task log
Reference URL: https://jingyan.baidu.com/article/0f5fb099efaa2c6d8334eae5.html?qq-pf-to=pcqq.c2c
SQL Server Learning _01