正文

存储过程2006-11-23 20:50:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/jixian/20685.html

分享到:

(1)--向表中添加一个字段 use tepgo create proc addd@idd int,@name char,@cityy char,@phonee int,@faxx intasdeclare @iddd intdeclare @namee chardeclare @cityyy chardeclare @phoneee intdeclare @faxxx int set @iddd=@idd   set @namee=@nameset @cityyy=@cityyset @phoneee=@phoneeset @faxxx=@faxx insert into customers values(@iddd,@namee,@cityyy,@phoneee,@faxxx)go   注释: set @iddd=@idd   set @namee=@nameset @cityyy=@cityyset @phoneee=@phoneeset @faxxx=@faxx set 后不能有逗号“,” 或者这几个语句改为: select @iddd=@idd, @namee=@name, @cityyy=@cityy, @phoneee=@phonee, @faxxx=@faxx select 后有逗号  declare @iddd intdeclare @namee chardeclare @cityyy chardeclare @phoneee intdeclare @faxxx int   或者 declare @iddd int,@namee char, @cityyy char, @phoneee int, @faxxx int  注意逗号  (2) 更新表inventory create proc prUpdateStatus@inventoryid int,@statusid intasupdate inventoryset statusid=@statusidwhere inventoryid=@inventoryid (3)多表查询 create procedure prListProperties@inventoryid intas select property.property property,inventoryproperty.value value,property.unit unitfrom inventoryproperty join propertyon inventoryproperty.propertyid=property.propertyidwhere inventoryproperty.inventoryid=@inventoryidgo 语法:Select tableA.a,b,c From tableA,tableB Where tableA.a=tableB.a 当两表有相同列名时,需在元素前加表名 tableA.a 。。。 单表内的模拟多表查询: Select first.a,second.a From tableA first,tableA second Where first.b = second.f (4)带返回值 create proc prGetLeaseScheduleID@InventoryId int,@LeaseScheduleId int outputasselect @LeaseScheduleId=LeaseScheduleIdfrom inventorywhere inventoryid=inventoryid declare @result intexec prgetleasescheduleid@leasescheduleid=@result output,    --不要写反,跟其他语言有所不同,赋值@inventoryid=121 select @result result 

阅读(2996) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册