sqlserver 存储过程
create database db
use db
create table sampleTable
(
fId int identity(1,1) primary key,
fName varchar(10),
fGrade int,
)
select * from sampleTable
insert into sampleTable values ('张柏',69);
insert into sampleTable values ('李玉梅',100);
insert into sampleTable values ('李四',100);
--普通存储过程
create proc queryInfo
as
select * from sampleTable
go
drop proc queryInfo
exec queryInfo
--传入参数--
create proc idIn
@id int
as
select * from sampleTable where fid =@id
go
drop proc idIn
exec idIn 1
--传入参数--
create proc nameIn
@name varchar(10)
as
select * from sampleTable where fname =@name
go
exec nameIn '张柏'
--传入、传出参数--
create proc nameOut
@id int,
@name varchar(10) output
as
begin
select @name=fname from sampleTable where fid =@id
end
drop proc nameOut
declare @name varchar(10)
exec nameOut 1,@name output
select @name
--带通配符的参数
create proc qwnbcOut
@name varchar(10) ='张%'
as
begin
select * from sampleTable where fname like @name
end
drop proc qwnbcOut
exec qwnbcOut '李%'
相关文档:
由于以前都是在sqlserver 2005处理,现在客户要求oracle数据库服务器,
最初的代码为:
allRecordSize = (Integer) rs1.getObject(1); //Integer allRecordSize=0;
当执行的时候报:BigDecimal无法转化为Integer类型
为了兼容两者修改后的代码为:
Object o = rs1.getObject(1);
&nbs ......
只是sqlserver 提供的远程数据访问函数; 在本地sqlserver 中取外部数据源数据时候可用;
对连接本地 oracle 操作远程 oracle 不能使用; 测试: pl/sql 中使用:
select * from openrowset(................); 无效!!!!!!!!!!!!!!
在oracle 中需要访问远程数据,需要建立一连接远程oracle 的 dblink ;
再用如下方 ......
对数据库进行多表操作,如果表与表之间存在依赖,那么显式的使用事务,可以保持对数据库操作的原子性。用Python访问SqlServer数据库,我使用pymssql库。今天在使用这个库的时候,发现一个问题。
问题大概是这样的:
我有两张表,一张主表(ClassInfo),一张从表(Student),Student表通过外键ClassID与ClassI ......
一 在Oracle中连接数据库
public class Test1 {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
&nbs ......
sqlserver字符串拆分(split)方法汇总
--方法0:动态SQL法
declare @s varchar(100),@sql varchar(1000)
set @s='1,2,3,4,5,6,7,8,9,10'
set @sql='select col='''+ replace(@s,',',''' union all select ''')+''''
PRINT @sql
exec (@sql)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ ......