sql server²éѯµ¼ÈëEXCEL
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 8.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)
select * from ±íÃû
Èç¹ûÊÇÉú³Éexcel時ÓÃbcp
--µ¼³ö²éѯµÄÇé¿ö
EXEC master..xp_cmdshell 'bcp "SELECT au_fname, au_lname from pubs..authors ORDER BY au_lname" queryout "c:\test.xls" /c -/S"·þÎñÆ÷Ãû" /U"Óû§Ãû" -P"ÃÜÂë"'
Ïà¹ØÎĵµ£º
-- ˵Ã÷:
-- 1. Ҫɾ³ý±í table_name, ÐëÏÈÅжϸñíÊÇ·ñÕý±»Êý¾Ý¿âÖÐÆäËü±íËùÒýÓÃ.
-- 2. Èç¹ûδ±»ÒýÓÃ, ¿ÉÖ±½Ó DROP TABLE table_name; ·ñÔò±ØÐëÏÈɾ³ýÒýÓñíµÄÔ¼Êø, ÔÙ DROP TABLE table_name.
-- 3. ÁíÍâ, table_name ÊÇ·ñÕýÒýÓÃÆäËü±íµÄÇé¿öÎÞÐ뿼ÂÇ.
-- ´´½¨Ö÷±í
CREATE TABLE tParent
......
Ö´ÐÐ Êý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºýÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥Åäģʽ£º
1£¬%£º±íʾÈÎÒâ0¸ö»ò¶à¸ö×Ö·û¡£¿ÉÆ¥ÅäÈÎÒâÀàÐͺͳ¤¶ÈµÄ×Ö·û£¬ÓÐЩÇé¿öÏÂÈôÊÇÖÐÎÄ£¬ÇëÔËÓÃÁ½¸ö°Ù·ÖºÅ£¨%%£©±íʾ¡£
±ÈÈç SELECT * from [user] WHERE u_na ......
±¾ÎÄÀ´×Ô£ºhttp://www.cnblogs.com/digjim/archive/2006/09/20/509344.html
ÎÒÃÇÖªµÀ£¬SQL Server 2005ºÍSQL Server 2000 Ïà±È½Ï£¬SQL Server 2005ÓкܶàÐÂÌØÐÔ¡£ÕâƪÎÄÕÂÎÒÃÇÒªÌÖÂÛÆäÖеÄÒ»¸öк¯ÊýRow_Number()¡£Êý¾Ý¿â¹ÜÀíÔ±ºÍ¿ª·¢ÕßÒѾÆÚ´ýÕâ¸öº¯ÊýºÜ¾ÃÁË£¬ÏÖÔÚÖÕÓڵȵ½ÁË£¡
ͨ³££¬¿ª·¢Õߺ͹ÜÀíÔ±ÔÚÒ»¸ö ......
select pcode from (
select h.k,h.d,h.m,h.u,l.areacode,
l.areacode||substr(h.u,4,length(h.u))||h.k pcode
from(
&nb ......
Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±í
SELECT * from table WITH (HOLDLOCK)
×¢Òâ: Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±íµÄÇø±ð
SELECT * from table WITH (HOLDLOCK)
ÆäËûÊÂÎñ¿ÉÒÔ¶ÁÈ¡±í£¬µ«²»ÄܸüÐÂɾ³ý
SELECT * from table WITH (TABLOCKX)
ÆäËûÊÂÎñ²»ÄܶÁÈ¡±í,¸üкÍɾ³ý
SELECT Óï¾äÖГ¼ÓËøÑ¡ÏŦÄÜ˵Ã÷
SQL ServerÌṩÁËÇ¿´ó¶øÍ ......