¹ØÓÚ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')
²éѯ½á¹ûÈçÏ£ ......
ËùνSQL×¢Èëʽ¹¥»÷£¬¾ÍÊǹ¥»÷Õß°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÄÊäÈëÓò»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁî¡£ÔÚijЩ±íµ¥ÖУ¬Óû§ÊäÈëµÄÄÚÈÝÖ±½ÓÓÃÀ´¹¹Ôì(»òÕßÓ°Ïì)¶¯Ì¬SQLÃüÁ»ò×÷Ϊ´æ´¢¹ý³ÌµÄÊäÈë²ÎÊý£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷¡£³£¼ûµÄSQL×¢Èëʽ¹¥»÷¹ý³ÌÀàÈ磺
¡¡¡¡¢Å ij¸öASP.NET WebÓ¦ÓÃÓÐÒ»¸ö ......