SQlÓαê
declare @CausName as char(20) declare @causenameid as int declare
@Description as varchar(200) declare @Caus_Id as int
declare @sign as char(20)
create table #tb ( Caus_Id int,CausName varchar(20),causNameid int,Caus_Description varchar(200),±êÖ¾ varchar(20))
DECLARE myCursor1 CURSOR FOR
select Caus_Id,Caus_PersonId,Caus_Description from tbObjection_Causer where Obje_Id=25
OPEN myCursor1
FETCH NEXT from myCursor1 INTO @Caus_Id,@causenameid,@Description
WHILE @@FETCH_STATUS =0
BEGIN
select @CausName=ÈËÔ±ÐÕÃû from zgong_xxi where id=@causenameid
insert into #tb
select Caus_Id=@Caus_Id,CausName=@CausName,causNameid=@causenameid,
Caus_Description=@Description,±êÖ¾=@sign where @Caus_Id is not null
FETCH NEXT from myCursor1 INTO @Caus_Id,@causenameid,@Description
END
CLOSE myCursor1
Deallocate myCursor1
select * from #tb
drop table #tb
Ïà¹ØÎĵµ£º
ϵͳº¯Êý
1.case when ... then ..else ..end(ÓÃÓÚ¶ÔÌõ¼þ½øÐвâÊÔ)
e.Select id,case when name='deepwishly' then 'ÀÏ´ó' else 'ÆäËû' end as Type
ÏÔʾ id type
1 ÀÏ´ó
2.cast()/convert() ǰÕß¾ßÓÐANSI SQL-92¼æÈÝÐÔ£¬ºóÕß¹¦ÄܸüÇ ......
string error_syntaxfromSQL, error_create
string new_sql, new_syntax
new_sql = 'SELECT emp_data.emp_id, ' &
& ......
SQL Server 2005 (MSSQLSERVER) ·þÎñ²»ÄÜÆô¶¯
ÔÒò:VIAÐÒ锸øÆôÓÃÁË£¬Í£ÓÓVIAÐÒé”ÎÊÌâ½â¾ö¡£
"VIAÐÒé"Í£Ó÷½·¨£º¿ªÊ¼->³ÌÐò->Microsoft SQL Server 2005->ÅäÖù¤¾ß->SQL Server Configuration Manager ->´ò¿ªºóÕÒµ½"SQL Server 2005 ÍøÂçÅäÖÃ"->MSSQLSERVER ÊôÐÔµÄÐÒé &nb ......
inner join(µÈÖµÁ¬½Ó) Ö»·µ»ØÁ½¸ö±íÖÐÁª½á×Ö¶ÎÏàµÈµÄÐÐ
left join(×óÁª½Ó) ·µ»Ø°üÀ¨×ó±íÖеÄËùÓмǼºÍÓÒ±íÖÐÁª½á×Ö¶ÎÏàµÈµÄ¼Ç¼
right join(ÓÒÁª½Ó) ·µ»Ø°üÀ¨ÓÒ±íÖеÄËùÓмǼºÍ×ó±íÖÐÁª½á×Ö¶ÎÏàµÈµÄ¼Ç¼
INNER JOIN Óï·¨£º
INNER JOIN Á¬½ÓÁ½¸öÊý¾Ý±íµÄÓ÷¨£º
SELECT * from ±í1 INNER JOIN ±í2 ON ±í1.×ֶκÅ=±í2 ......