declare @str varchar(50)
declare @i int
set @str = ''
set @i=0
while @i<50
begin
set @str = @str + char(33 + cast(ceiling(rand() * 80) as int))
set @i = @i+1
end
select @str ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(Create£¬Alter£¬Drop£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(Select£¬Delete£¬Update£¬Insert)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
Create DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢ËµÃ÷£º´´½¨Ð±í
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
¸ù¾ÝÒÑÓÐµÄ±í´´½¨ÐÂ±í£º
A£ºcreate table tab_new like tab_old (ʹÓÃ¾É±í´´½¨Ð±í)
B£ºcreate table tab_new as select col1,col2&hellip ......
sql serverÑ¡ÔñÁË»ìºÏģʽÎÊÌâ
ÒòΪҪѡÔñ»ìºÏģʽ²ÅÄÜʹÓÃsaÓû§µÇ¼µÄÎÊÌâ
È»ºóÆóÒµ¹ÜÀíÆ÷ÀïÃ澹ȻѡÁËÒÔºóûÓÐЧ¹û ÓÀÔ¶¶¼Êǽöwindowsģʽ
ÎÞÓï ²»¶ÏÖØÆômssql ÓÖÑ¡Ôñ »ìºÏģʽ ´óÔ¼¼¸·ÖÖÓºó¾¹È»¿ÉÒÔÑ¡ÔñÁË
zhenTMD µÄÎÞÄΣ¡ ......
[code=SQL][/code]
--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--Êý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓͼ
DROP VIEW --´ÓÊý¾Ý¿âÖÐɾ³ýÊÓͼ
CREATE INDEX --ΪÊý¾Ý¿â±í´´½¨Ò»¸öË÷Òý
DROP INDEX --´ÓÊý¾Ý¿âÖÐɾ³ýË÷Òý
CREATE PROCEDURE --´´½¨Ò»¸ö´æ´¢¹ý³Ì
DROP PROCEDURE --´ÓÊý¾Ý¿âÖÐɾ³ý´æ´¢¹ý³Ì
CREATE TRIGGER --´´½¨Ò»¸ö´¥·¢Æ÷
DROP TRIGGER --´ÓÊý¾Ý¿âÖÐɾ³ý´¥·¢Æ÷
CREATE SCHEMA --ÏòÊý¾Ý¿âÌí¼ÓÒ»¸öÐÂģʽ
DROP SCHEMA --´ÓÊý¾Ý¿âÖÐɾ³ýÒ»¸öģʽ
CREATE DOMAIN --´´½¨Ò»¸öÊý¾ÝÖµÓò
ALTER DOMAIN --¸Ä±äÓò¶¨Òå
DROP DOMAIN --´ÓÊý¾Ý¿âÖÐɾ³ýÒ»¸öÓò
--Êý¾Ý¿ØÖÆ
GRANT --ÊÚÓèÓû§·ÃÎÊȨÏÞ
DENY --¾Ü¾øÓû§·ÃÎÊ
REVOKE --½â³ýÓû§·ÃÎÊÈ ......
--Excelµ¼ÈëSQL SERVERÖÐ
--±í½á¹¹²»´æÔÚ¿ÉÒÔʹÓÃ
--ÆôÓÃAd Hoc Distributed Queries£º
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
select * into serv_user_bak1 from
OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=yes;database=c:\test.xls;','select * from [Sheet1$]')
---ʹÓÃÍê³Éºó£¬¹Ø±ÕAd Hoc Distributed Queries£º
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
-----------------------------------------------------------
--±í½á¹¹´æÔÚ¿ÉÒÔʹÓÃ
--ÆôÓÃAd Hoc Distributed Queries£º
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
insert into serv_user_bak1
SELECT * from
OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=yes;database=c:\test.xls;','select * from [Sheet1$]')
---ʹÓÃÍê³Éºó£¬¹Ø±ÕAd Hoc Distributed Queries£º
exec sp_configure 'Ad Hoc Distributed Qu ......
SQLʹÓÃconvertÀ´È¡µÃdatetimeÈÕÆÚÊý¾Ý£¬ÒÔÏÂʵÀý°üº¬¸÷ÖÖÈÕÆÚ¸ñʽµÄת»»,
¿ÉÒÔͨ¹ý²éѯÓï¾ä¼°²éѯ½á¹ûÀ´ÏÔʾ²»Í¬µÄ¸ñʽ£¬Èç¹ûÊÇDate¸ñʽҲ¿ÉÒÔÓãº
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06
Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06
Select CONVERT(varchar(100), GETDATE(), 5): 16-05-06
Select CONVERT(varchar(100), GETDATE(), 6): 16 05 06
Select CONVERT(varchar(100), GETDATE(), 7): 05 16, 06
Select CONVERT(varchar(100), GETDATE(), 8): 10:57:46
Select CONVERT(varchar(100), GETDATE(), 9): 05 16 2006 10:57:46:827AM
Select CONVERT(varchar(100), GETDATE(), 10): 05-16-06
Select CONVERT(varchar(100), GETDATE(), 11): 06/05/16
Select CONVERT(varchar(100), GETDATE(), 12): 060516
Select CONVERT(varchar(100), GETDATE(), 13): 16 05 2006 10:57:46:937
Select CONVERT(varchar(100), GETDATE(), 14): 10:57:46:967
......
×ܼǼÊý:4346; ×ÜÒ³Êý:725; ÿҳ6 Ìõ;
Ê×Ò³ ÉÏÒ»Ò³ [4] [5] [6] [7] 8
[9] [10] [11] [12] [13] ÏÂÒ»Ò³ βҳ