本人写了一个测试闰年的函数,在sql server 2000顺利运行通过:
if exists( select * from sysobjects where type = 'fn' and name='isLeapYear')
drop function isLeapYear
go
create function isLeapYear
(@year int)
returns int
as
begin
declare @days int
set @days = 365 if @year % 4 = 0
if @year % 100 <> 0
set @days = 366
if @year % 400 = 0
set @days = 366
return @days
end
但是我用adoQuery1.sql.add方法将上述字符串加入,并execsql之,却出现错误告诉我'go 附近有语法错误',请问如何改正?
if exists( select * from sysobjects where type = 'fn' and name='isLeapYear')
drop function isLeapYear
go
create function isLeapYear
(@year int)
returns int
as
begin
declare @days int
set @days = 365 if @year % 4 = 0
if @year % 100 <> 0
set @days = 366
if @year % 400 = 0
set @days = 366
return @days
end
但是我用adoQuery1.sql.add方法将上述字符串加入,并execsql之,却出现错误告诉我'go 附近有语法错误',请问如何改正?
解决方案 »
- delphi CreateProcessWithLogon
- 想在系统中集成word的编辑环境,怎么做到?大侠都来看看啊
- 请帮忙做个查询,在线等,TKS!
- clientDataSet怎样屏蔽掉字段.
- 请哪位大虾详细解释一下“数据字典”到底是怎么回事?我用的是SQL SERVER2000数据库
- 请问如何将word文件从数据库中读出?
- 可否将指定的控件放入“容器”中?
- 怎么样使messagedlg出现的标题和内容以及按钮上的文字都是自己定义的中文?
- 在怎样的需求下用B/S结构,怎样的需求下用三层结构?
- 我想在一個全局單元中寫一個控制按鈕使能的過程,但是按鈕有 tspeedbutton ;tbutton
- 请教 directx 的问题
- LIST之间数据移动,简单问题--在线等解答~!
drop function isLeapYear
然后执行.再加后面的(GO不要),然后再执行
Set @k=[dbo].isLeapYear(2005)
select @k
我的函数是要用在不同的数据库上滴~~
问题已经解决!把'Go'去掉分两次execsql!
结帖!