sql Óï¾ä
select * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHEREselect * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHERE species='dog' and sex='f';
select * from pet WHERE species='snake' or species='cat';
SELECT * from pet WHERE (species='cat' and sex='m') or (species='dog' and sex='f');
SELECT name,birth from pet;
SELECT owner from pet;
SELECT distinct owner from pet;
SELECT name,species,birth from pet where species='dog' or species='cat';
=======================================================================
select name,birth from pet ORDER BY birth;
select name,birth from pet order by birth desc;
select name,species,birth from pet order by species,birth desc;
========================================================================
select name,birth,curdate(),(year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) as age from pet order by name;
select name,birth,curdate(),(year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) as age from pet order by age;
select name,birth,curdate(),(year(curdate())-year(birth))-(right(curdate(),5)<right(birth,5)) as age from pet WHERE death IS NOT NULL ORDER BY age;
select name,birth ,month(birth) from pet;
SELECT name, birth from pet WHERE MONTH(birth) = 5;
SELECT name, birth from pet WHERE MONTH(birth) = MONTH(DATE_ADD(CURDATE(),INTERVAL 1 MONTH));
SELECT name, birth from pet WHERE MONTH(birth) = MOD(MONTH(CURDATE()), 12) + 1;
select 1 is null,1 is not null;
select 0 is null, 0 is not null,'' is null,'' is not null;
SELECT * from pet WHERE name LIKE 'b%';
SELECT * from pet WHERE name LIKE '%fy';
SELECT * from pet WHERE name LIKE '%w%';
SELEC
Ïà¹ØÎĵµ£º
1.ͨ¹ý¹¤¾ßDTSµÄÉè¼ÆÆ÷½øÐе¼Èë»òµ¼³ö
¡¡¡¡DTSµÄÉè¼ÆÆ÷¹¦ÄÜÇ¿´ó£¬Ö§³Ö¶àÈÎÎñ£¬Ò²ÊÇ¿ÉÊÓ»¯½çÃæ£¬ÈÝÒײÙ×÷£¬µ«ÖªµÀµÄÈËÒ»°ã²»¶à£¬Èç¹ûÖ»ÊǽøÐÐSQL ServerÊý¾Ý¿âÖв¿·Ö±íµÄÒÆ¶¯£¬ÓÃÕâÖÖ·½·¨×îºÃ£¬µ±È»£¬Ò²¿ÉÒÔ½øÐÐÈ«²¿±íµÄÒÆ¶¯¡£ÔÚSQL Server Enterprise ManagerÖУ¬Õ¹¿ª·þÎñÆ÷×ó±ßµÄ+£¬Ñ¡ÔñÊý¾Ý¿â£¬ÓÒ»÷£¬Ñ¡ÔñAll tasks/I ......
sqlÊý¾ÝÀàÐÍÏê½â
(1)¶þ½øÖÆÊý¾ÝÀàÐÍ
¡¡¡¡¶þ½øÖÆÊý¾Ý°üÀ¨ Binary¡¢Varbinary ºÍ Image
¡¡¡¡Binary Êý¾ÝÀàÐͼȿÉÒÔÊǹ̶¨³¤¶ÈµÄ(Binary),Ò²¿ÉÒÔÊDZ䳤¶ÈµÄ¡£
¡¡¡¡Binary[(n)] ÊÇ n λ¹Ì¶¨µÄ¶þ½øÖÆÊý¾Ý¡£ÆäÖУ¬n µÄȡֵ·¶Î§ÊÇ´Ó 1 µ½ 8000¡£Æä´æ´¢ñ¿µÄ´óСÊÇ n + 4 ¸ö×Ö½Ú¡£
¡¡¡¡Varbinary[(n)] ÊÇ n λ±ä³¤¶ÈµÄ¶þ½øÖÆÊ ......
SQL Server 2005 ûÓÐSQL Server Management Studio
°²×°visual studio 2005µÄʱºòϵͳҲװÁËSQL 2005¡£Çë×¢Ò⣬Õâʱ°²×°ÉϵÄSQL2005ÊÇExpress°æ±¾µÄ£¬¼È²»ÊÇÆóÒµ°æ£¬Ò²²»ÊÇ¿ª·¢Õß°æ¡£ÕâʱµÄExpress°æÊÇûÓа²×°SQL Server Management Studio µÄ£¬Ö»ÓÐÅäÖù¤¾ß£¬Ò²¾ÍÊÇ˵ÄãÔÚ¿ªÊ¼²Ëµ¥Ö»¿´µÃµ½ÅäÖù¤¾ß¡£
Õâʱ ......
from: http://blog.163.com/ck275601774/blog/static/1230468012009631113559291/
--ÈÕÆÚת»»²ÎÊý
select CONVERT(varchar,getdate(),120)
--2009-03-15 15:10:02
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
--20090315151201
select CONVERT(varchar(12) , getdate ......
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
Àý: Select * from tableName
Exec('select * from tableName')
& ......