SQL函数调用
函数如下
CREATE FUNCTION StockBalance_AmountIn(@SortID int)
RETURNS numeric(18,4)
AS
BEGIN
Declare @dblReturn numeric(18,4)
Select @dblReturn = SUM(AmountCurrentMonthIn) from AT_Materiel_StockBalance Where SortID = @SortID
Return (@dblReturn)
END
调用方法
select dbo.StockBalance_AmountIn(2523)
这里头需要加dbo
=========================
表格变量
USE [mbmxdb]
GO
/****** Object: UserDefinedFunction [dbo].[uf_GetResearcherTable] Script Date: 04/23/2010 09:50:47 ******/
SET QUOTED_IDENTIFIER ON
GO
CREATE function [dbo].[uf_GetResearcherTable](@UserID varchar(50))
returns @t table(col varchar(50))
as
begin
declare @temp table (ID int IDENTITY (1, 1) NOT NULL , OrderRight varchar(10),Researcher varchar(50))
declare @ResearcherInfo varchar(50)
DECLARE @ID int
SET @ResearcherInfo=''
insert into @temp(OrderRight,Researcher)
( SELECT
RI.OrderRight as OrderRight,
(CASE WHEN RI.IsAnalyst=1 THEN '分析师'+':'+UserName
ELSE '联系人'+':'+UserName
END) as Researcher
from kinghing..vemployeeinfo_yjs Vyjs Inner Join
(
Select
DISTINCT MR.RelatedID,MR.OrderRight,MI.IsAnalyst,MR.Type,MR.NameFontStyle,MR.PhoneFontStyle,MR.EmailFontStyle,MR.Separator,Mi.CertificateID
from MBMXResearcherInfo MI Inner Join
(Select RelatedID,OrderRight,Type,NameFontStyle,PhoneFontStyle,EmailFontStyle,Separator from MBMXResearcherInfoReferNew where UserID=@UserID) MR
On MI.UserID=MR.RelatedID
) RI
On Vyjs.UserID=RI.RelatedID where Vyjs.userstatus <4
)
WHILE ((
相关文档:
注释:只适合单表单列数据,
create database test
go
use test
go
create table users
(
:id int identity(1,1) primary key not null,
:name nvarchar(20)
)
go
create proc sp_Inserts
@Names nvarchar(4000)
as
declare @Name nvarchar(20),@ErrorSum int
:set @ErrorSum = 0
:begin tra ......
merge [target] t
using [source] s on t.id = s.id
when matched then update t.name = s.name, t.age = s.age -- use "rowset1"
when not matched then insert values(id,name,age) -- use "rowset2"
when source not matched then delete; -- use "rowset3"
MERGE dbo.table AS im ......
用sql操作oracle的blob字段
1、查询
select utl_raw.cast_to_varchar2(dlob),id from system.t_htinfo
2、插入
insert into system.t_htinfo values ('3',utl_raw.cast_to_raw('你'));
3、更新
update system.t_htinfo set fld_value=utl_raw.cast_to_raw('1') where fh_nm=1820648 and form_index=52
......
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......
很早做过的一个delphi项目,把里面用到的技术总结一下,主要是针对象我这样的delphi新手,技术上做个积累吧!
假设我们的数据库配置文件ServerInfo.ini内容如下:
[ServerInfo]
ServerIP=192.168.1.5
SQLDBName=Data
SQLUserID=sa
SQLPwd=
我们定义一个连接数据库的过 ......