重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

关于写sqlserver的信息

如何写sqlserver的ini配置文件

uses

成都创新互联专注于双牌企业网站建设,响应式网站开发,成都商城网站开发。双牌网站建设公司,为双牌等地区提供建站服务。全流程按需策划设计,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务

Inifile;

var

ini:tinifile;

SqlServer,Sqlusr,SqlPwd:string;

begin

ini:=tinifile.create('My.ini');

SqlServer

:=ini.ReadString('Server','SqlServer','');

//读取INI配置文件服务器IP地址

Sqlusr

:=ini.ReadString('Server','Sqlusr','');

//读取INI配置文件SQL账号

SqlPwd

:=ini.ReadString('Server','Sqlpwd','');

//读取INI配置文件SQL密码

//然后使用ADOquery将账号密码加入后连接就可以了

end;

ini配置文件:

[Server]

SqlServer=127.0.0.1

Sqlusr=sa

Sqlpwd=123456

SQLServer 语句怎么写

嵌套比较多,你慢慢看。

select D.address, D.time, D.value

from (select A.address, A.time, A.value

from A

union

select B.address, B.time, B.value

from B) D,

(select C.Address, max(C.time) as maxTime

from (select A.address, A.time, A.value

from A

union

select B.address, B.time, B.value

from B) C

group by C.address) E

where D.address = E.address

and D.time = E.maxTime

编写一个SQLSERVER 存储过程

代码是最好的文字,不多说,请看我的代码,并给分,呵呵。

--step1. 建表

if exists(select * from sysobjects where id=object_id('student') and objectproperty(id,'IsTable')=1)

drop table student

go

create table student

(

id int identity(100,10) not null

,sname varchar(10) not null

,sno varchar(30) not null

)

go

--step2.建存储过程

if exists(select * from sysobjects where id=object_id('proc_demo') and objectproperty(id,'IsProcedure')=1)

drop procedure proc_demo

go

create procedure proc_demo

@o_maxid int output

as

set nocount on

--如果希望大小写敏感,使用第一句,因为SQL Server默认是大小写不敏感的

--update student set sno='cay_'+sno where ascii(substring(sname,1,1))=87 and ascii(substring(sname,2,1))=65 and sno not like 'cay_%'

update student set sno='cay_'+sno where sname like 'WA%' and sno not like 'cay_%'

print convert(varchar(10),@@rowcount)+'条记录符合条件并被处理'

select @o_maxid=max(id) from student where id=100

if(@o_maxid is null) print '没有找到符合条件的最大记录'

set nocount off

go

--测试数据1

truncate table student

set identity_insert student on

insert into student(id,sname,sno)values(1,'WA1','1');

insert into student(id,sname,sno)values(2,'wa2','2');

insert into student(id,sname,sno)values(3,'3','3');

set identity_insert student off

go

--测试数据2

truncate table student

insert into student(sname,sno)values('WA1','1');

insert into student(sname,sno)values('wa2','2');

insert into student(sname,sno)values('3','3');

go

--测试过程

declare @maxid int

exec proc_demo @maxid out

print '最大id是'+convert(varchar(10),@maxid)

go


标题名称:关于写sqlserver的信息
链接地址:http://cqcxhl.com/article/dsdphcj.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP