Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL´´½¨Êý¾Ý¿â¡¢±í¡¢´æ´¢¹ý³Ì¼°µ÷ÓÃ

--Èç¹û´æÔÚÊý¾Ý¿âprogrammerPay  ¾Íɾ³ý
if exists (select * from sysdatabases where name='programmerPay')
drop database programmerPay
go
--´´½¨Êý¾Ý¿âprogrammerPay
create database programmerPay
on primary
(
name ='programmerPay_data',
filename='D:\programmerPay\programmerPay_data.mdf',
maxsize=3mb,
filegrowth=15%
)
log on
(
name ='programmerPay_log',
filename='D:\programmerPay\programmerPay_log.ldf',
maxsize=1mb,
filegrowth=15%
)
go
use programmerPay
go
--´´½¨±íprowage
create table prowage
(
id int identity(1,1) not null,--Ö÷¼ü ±êʶÁÐ
Pname char(10) not null,--³ÌÐòÔ±ÐÕÃû
wage  int  not null--³ÌÐòÔ±¹¤×Ê
)
go
--Ϊ±íprowage id ×Ö¶ÎÌí¼ÓÖ÷¼üÔ¼Êø
alter table prowage
add constraint PK_id primary key(id)
--²åÈë²âÊÔÊý¾Ý
insert into prowage (pname,wage)
values ('ÕÅÈý',5000)
insert into prowage (pname,wage)
values ('ÀîËÄ',1200)
insert into prowage (pname,wage)
values ('¶þÔÂ',1700)
insert into prowage (pname,wage)
values ('À¶Ìì',5700)
insert into prowage (pname,wage)
values ('Ñô¹â',8700)
insert into prowage (pname,wage)
values ('ÉñÖÝ',1100)
insert into prowage (pname,wage)
values ('Ôø¾­²Ø',1300)
insert into prowage (pname,wage)
values ('ruo',1200)
insert into prowage (pname,wage)
values ('chend',1400)
--Èç¹û´æÔÚ´æ´¢¹ý³Ìproc_addWage1  ¾Íɾ³ý
if exists (select * from sysobjects where name='proc_addWage1')
drop procedure proc_addWage1
go
--´´½¨´æ´¢¹ý³Ìproc_addWage1
create procedure proc_addWage1
as
set nocount on
declare @firstwage  int
select @firstwage=sum(wage) from prowage
while (1=1)
    begin
          declare @notpass int, @count int--¶¨ÒåÁ½¸ö±äÁ¿ û´ïµ½2200µÄÈËÊýºÍ×ÜÈËÊý
          select @notpass=count(*) from prowage where wage<2200
          select @count =count(*) from prowage
       if(@notpass*


Ïà¹ØÎĵµ£º

OracleÖÐÀûÓÃÒ»ÌõSQLÉú³É10ÍòÌõ¼Ç¼

  ×öÊý¾Ý¿â¿ª·¢»ò¹ÜÀíµÄÈ˾­³£Òª´´½¨´óÁ¿µÄ²âÊÔÊý¾Ý£¬¶¯²»¶¯¾ÍÐèÒªÉÏÍòÌõ£¬Èç¹ûÒ»ÌõÒ»ÌõµÄ¼È룬ÄÇ»áÀË·Ñ´óÁ¿µÄʱ¼ä£¬±¾ÎĽéÉÜÁËOracleÖÐÈçºÎͨ¹ýÒ»ÌõSQL¿ìËÙÉú³É´óÁ¿µÄ²âÊÔÊý¾ÝµÄ·½·¨¡£
²úÉú²âÊÔÊý¾ÝµÄSQLÈçÏ£º
SQL> select rownum as id,
  2         &nb ......

¸÷ÖÖÊý¾Ý¿âsqlÓï¾äÈ¡±íÖÐn mÌõÊý¾Ý

ÃüÌ⣺д³öÒ»ÌõSqlÓï¾ä£º È¡³ö±íAÖеÚ31µ½µÚ40¼Ç¼£¨×Ô¶¯Ôö³¤µÄID×÷ΪÖ÷¼ü,  ×¢Ò⣺ID¿ÉÄܲ»ÊÇÁ¬ÐøµÄ¡££©
oracleÊý¾Ý¿âÖУº
1¡¢select * from A where rownum<=40 minus select * from A where rownum<=30
sqlserverÊý¾Ý¿âÖУº
1¡¢select top 10 * from A where id not in (select top 30 id from A )
2¡¢s ......

Ҳ̸SQL¸÷ÖÖÁ¬½Ó£¨JOIN£©

×î½ü¹«Ë¾ÔÚÕÐÈË£¬Í¬ÊÂÎÊÁ˼¸¸ö×ÔÈÏΪÊý¾Ý¿â¿ÉÒÔµÄӦƸÕß¹ØÓÚ¿âÁ¬½ÓµÄÎÊÌ⣬»Ø´ð²»¾¡ÀíÏë¡«
ÏÖÔÚÔÚÕâдд¹ØÓÚËüÃǵÄ×÷ÓÃ
¼ÙÉèÓÐÈçÏÂ±í£º
Ò»¸öΪͶƱÖ÷±í£¬Ò»¸öΪͶƱÕßÐÅÏ¢±í¡«¼Ç¼ͶƱÈËIP¼°¶ÔӦͶƱÀàÐÍ£¬×óÓÒÁ¬½Óʵ¼Ê˵ÊÇÎÒÃÇÁªºÏ²éѯµÄ½á¹ûÒÔÄĸö±íΪ׼¡«
1£ºÈçÓÒ½ÓÁ¬ right join »ò right outer join£º
ÎÒÃÇÒÔÓÒ±ß ......

C#²Ù×÷SQL ServerÊý¾Ý¿â(ת)


Visual C#Öж¯Ì¬²Ù×÷SQL ServerÊý¾Ý¿â £¨1£©
 
·¢²¼Ê±¼ä£º2003.01.14 10:09     À´Ô´£ºÈüµÏÍø    ×÷ÕߣºÍõ¿­Ã÷
ÔÚ±àдÊý¾Ý¿âÓ¦ÓóÌÐòµÄʱºò£¬ÎÒÃÇ¿ÉÒÔͨ¹ýSQLÓï¾äÀ´¶¯Ì¬´´½¨¡¢ÐÞ¸ÄÊý¾Ý¿âÒÔ¼°ÆäÖеĶÔÏó¡£±¾ÎÄÎÒ¾ÍÏò´ó¼Ò½éÉÜÈçºÎÔËÓÃVisual C#À´¶¯Ì¬²Ù×÷SQL ServerÊý¾Ý¿ ......

Ê¡ÊÐÖ®Ò» ´´½¨È«¹úÊ¡ÊÐSql±í

×î½üÓÐÅóÓÑÓöµ½Ê¡ÊеÄÎÊÌ⣬ÏëÏë×Ô¼º½ñºóÒ²ÓпÉÄÜ»áÓöµ½£¬ËùÒÔ¾Í×Ô¼ºÔÚÍøÉÏдд£¬ËÑËÑ£¬Ö÷ÒªÊǶÔ×Ô¼º½ñºóÓвο¼
--´´½¨Êý¾Ý¿â
create database NationalAll
Go
--ʹÓÃNationalAllÊý¾Ý¿â
use  NationalAll
Go
--´´½¨Ê¡¼¶±í
Create Table Province
(
ProID int primary key not null,
ProName nvarchar(50) n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ