¹ØÓÚSQL SERVER Êý¾Ý²ð·Ö
if object_id('tb') is not null drop table tb
go
create table tb([A] varchar(10),[B] int)
insert tb
select 'bcd',1 union all
select 'bcde',2 union all
select 'cd',3
go
¸öÈË·ÖÎöÕâµÀÌâµÄ˼·ÊÇ£º
ͨ¹ýSubstring() À´Ñ»··Ö¸î B ÁÐϵÄ×Ö·û´®¡£¡£
--ÏëµÃµ½µÄ½á¹û£º
/**
a b
---- -----------
b 1
c 1
d 1
b 2
c 2
d 2
e 2
c 3
d 3
£¨ËùÓ°ÏìµÄÐÐÊýΪ 9 ÐУ©
**/
£¨1£©£ºselect
substring(a.A,b.number,1) as a,a.b
from tb a,
master..spt_values b
where b.type='P' and b.number>0
and b.number<len(a.a)
/**
a b
---- -----------
b 1
c 1
d 1
b 2
c 2
d 2
e 2
c 3
d 3
£¨ËùÓ°ÏìµÄÐÐÊýΪ 9 ÐУ©
**/
£¨2£©
SELECT TOP 100 ID=IDENTITY(INT,1,1) INTO #NUM from SYS.SYSCOLUMNS A,SYS.SYSCOLUMNS B
SELECT
A.b,[VALUE]=SUBSTRING(A.a,B.ID,1)
from
#TB A,#NUM B
WHERE
b.id <=len(a.a)
/*
b VALUE
----------- -----
1 b
1 c
1 d
2 b
2 c
2 d
2 e
3 c
3 d
Ïà¹ØÎĵµ£º
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 Server2005°æ±¾ºÅ£º
Ҫȷ¶¨ËùÔËÐÐµÄ SQL Server 2005 µÄ°æ±¾£¬ÇëʹÓà SQL Server Management Studio Á¬½Óµ½ SQL Server 2005£¬È»ºóÔËÐÐÒÔÏ Transact-SQL Óï¾ä£º(´ËSQLÓï¾äͬÑùÊÊÓÃÓÚSQL2000)
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
²éѯ½á¹ûÈçÏ£ ......
1.×Ö·û´®º¯Êý
³¤¶ÈÓë·ÖÎöÓÃ
datalength(Char_expr) ·µ»Ø×Ö·û´®°üº¬×Ö·ûÊý,µ«²»°üº¬ºóÃæµÄ¿Õ¸ñ
substring(expression,start,length) ²»¶à˵ÁË,È¡×Ó´®
right(char_expr,int_expr) ·µ»Ø×Ö·û´®ÓÒ±ßint_expr¸ö×Ö·û
×Ö·û²Ù×÷Àà
upper(char_expr) תΪ´óд
lower(char_expr) תΪСд
space(int_expr) Éú³Éint_expr¸ ......
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(varch ......
MySQLÖÐÎIJο¼ÊÖ²á- 7 MySQL ÓïÑԲο¼
<!--
body { font-size: 9pt; }
a:hover{color:red;}
a.t1:visited{color:red;}
-->
DATABASE()
·µ»Øµ±Ç°µÄÊý¾Ý¿âÃû×Ö¡£
mysql> select DATABASE();
-> 'test'
Èç¹ûûÓе±Ç°µÄÊý¾Ý¿â£¬DATABASE()
·µ»Ø¿Õ×Ö·û´®¡£
USER()
¡¡
SYSTEM_USER()
......