简单的sql语句 数据与汇总。 高手多多指点。

源代码在线查看: function.sql

软件大小: 11 K
上传用户: janeljh1
关键词: sql 数据 高手
下载地址: 免注册下载 普通下载 VIP

相关代码

				use northwind
				go
				
				 create function fn_newregion
				(@myinput nvarchar(30))
				returns nvarchar(30)
				begin 
				  if @myinput is null
				  set @myinput = 'Not Applicable'
				  return @myinput
				end
				go
				
				select * from employees
				go
				
				insert employees 
				(lastname,firstname)
				values 
				('David','Hao')
				go
				
				select region from employees
				go
				
				select dbo.fn_newregion(region) as region from employees
				go
				
				--这里必须注明自定义函数的所有者,否则会显示错误
				
				alter function fn_newregion
				(@myinput nvarchar(30))
				returns nvarchar(30)
				begin 
				  if @myinput is null
				  set @myinput = '涛哥万岁'
				  return @myinput
				end
				go
				
				select * from shippers
				go
				
				alter function dbo.fu_shippers
				(@companyname nvarchar(40))
				returns table
				as
				return
				(
				 select * from shippers
				 where companyname=@companyname
				)
				go
				
				
				select * from dbo.fu_shippers('speedy express')			

相关资源