mssqlÈçºÎcreate×Ö¶ÎÄØ£¿
create db ÊÇн¨Êý¾Ý¿â
create table ÊÇн¨±í
ÄÇн¨×Ö¶ÎÄØ£¿ лл¡£
×Ô¼ºµ½sqlserverÎĵµÖвéÕÒcreateµÄÓ﷨ʾÀý°É
SQL code:
ÏÂÀýÏÔʾ pubs Êý¾Ý¿âÖÐËù´´½¨µÄÈý¸ö±í£¨jobs¡¢employee ºÍ publishers£©µÄÍêÕû±í¶¨Ò壬ÆäÖаüº¬ËùÓеÄÔ¼Êø¶¨Òå¡£
/* ************************** jobs table ************************** */
CREATE TABLE jobs
(
job_id smallint
IDENTITY(1,1)
PRIMARY KEY CLUSTERED,
job_desc varchar(50) NOT NULL
DEFAULT 'New Position - title not formalized yet',
min_lvl tinyint NOT NULL
CHECK (min_lvl >= 10),
max_lvl tinyint NOT NULL
CHECK (max_lvl <= 250)
)
/* ************************* employee table ************************* */
CREATE TABLE employee
(
emp_id empid
CONSTRAINT PK_emp_id PRIMARY KEY NONCLUSTERED
CONSTRAINT CK_emp_id CHECK (emp_id LIKE
'[A-Z][A-Z][A-Z][1-9][0-9][0-9][0-9][0-9][FM]' or
emp_id LIKE '[A-Z]-[A-Z][1-9][0-9][0-9][0-9][0-9][FM]'),
/* Each employee ID consists of three characters that
represent the employee's initials, followed by a five
digit number ranging from 10000 through 99999 and then the
employee's gender (M or F). A (hyphen) - is acceptable
for the middle initial. */
fname varchar(20) NOT NULL,
minit char(1) NULL,
lname varchar(30)
Ïà¹ØÎÊ´ð£º
ÏÖÔÚÁ¬µÄÒ»Ô¶³Ìmssql£¬Ã¿´Î²éѯ±È½ÏÂý£¬ÏÖÔÚÏëһϰÑËùÓмǼ²éѯ³öÀ´ÓÃÊý¾Ý¼¯±£´æÆðÀ´£¬È»ºóÕë¶ÔÊý¾Ý¼¯Ôٴβéѯɸѡ¡£
ÏÖÔÚÎÊÏÂÄǸöÊý¾Ý¼¯ÈçºÎ±£´æ²éѯ¼Ç¼£¬¶øÔٴβéѯ£¬¶àлÁË¡£
¿ÉÒÔ°ÑÊý¾Ý¼¯ÖеÄÊý¾Ý·Åµ½ÄÚ´ ......
ÔÚvbscriptÖв»ÓÃon error resume nextÈçºÎÅжÏmssqlÓï·¨´íÎó£¡
TRY CATCH?
»òÕßʹÓÃÁ÷³Ì¿ØÖÆÓï¾ä
if
else
²»ÓÃon error ÓÃÄǸöÎҾͲ»ÐèÒªÔÚÕâÀïÑ°ÕÒ´ð°¸
ÒýÓÃ
²»ÓÃon error ÓÃÄǸöÎҾͲ»Ðè ......
±íµÄ½á¹¹ÈçÏ£º
±í1£ºtb_big
×ֶΣºfalseIDÖµ£º1£¬2£¬3
×ֶΣºbigtype Öµ£ºA£¬B£¬C£¨ÓëfalseIDµÄÖµµÄλÖÃÒ»Ò»¶ÔÓ¦£¬¼´1¶ÔÓ¦A£¬2¶ÔÓ¦B£©
±í2£ºtb_small
×ֶΣºfalseID£¨Óëtb_bigµÄfalseID ......
accessʱ²éѯËٶȻ¹Âù¿ìµÄ£¬ÏÖÔÚת³ÉmssqlÁË£¬Êý¾ÝÁ¿²¢²»´ó£¬Í¨³£Êý¾ÝÁ¿¶àЩµÄ¾ÍÊǼ¸Ç§Ìõ£¬µ±È«²¿ÁгöÊý¾ÝʱËÙ¶ÈÒ²²»Âý£¬¾ÍÊÇ°´Ìõ¼þËÑË÷ʱ¾ÍÂýÁË£¬ÇëÎÊÊDz»ÊǸúlikeÓйذ¡£¬µ«ÒÔÇ°ÓÃaccessÂù¿ìµÄ°¡£¬Ò²½¨Á¢ÁËË÷ÒýÁË ......