首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

初学者求救,这个SQL要如何写

2012-01-31 
菜鸟求救,这个SQL要怎么写?Select*FromEMPLOYEEWhereEMP_IDlike[%EmpIDParm]Parameters写法如下:Dimm_objA

菜鸟求救,这个SQL要怎么写?
Select   *   From   EMPLOYEE   Where   EMP_ID   like   [%EmpIDParm]

Parameters   写法如下:
Dim   m_objADMIN_EmployeeMnt_EmployeeGetLikeEmpIDParms   As   BDParameters

Dim   m_objEmpIDParm   As   BDParameter

Dim   m_vtEmpIDParm   As   Variant

Set   m_objEmpIDParm   =   m_objADMIN_EmployeeMnt_EmployeeGetLikeEmpIDParms.NewParameter( "EmpIDParm ",   m_vtEmpIDParm)
上面是SQL的写法样式,都要写成上面的形式,
简单的查询还好些我现在有一个查询日期的条件如下:
预售日期:   从   A   到   B.   如果   A   有,   B没有   则为   >   A;   如果   B   有   A   没有,   则为   <   B.
时间值是手工输入的
写成如上的形式高手给写个,谢谢。


[解决办法]
creare proc dbo.proc_getdata()
@a datetime,
@b datetime
as
set nocount on
if @a is null and @b is null return

if @a+@b> ' '
select * from table_pqs where a> @a and b <@b
else if @a is null
select * from table_pqs where a> @a
else if @b is null
select * from table_pqs where b <@b

go
[解决办法]
creare proc dbo.proc_getdata(
@a datetime,
@b datetime
)
as
set nocount on
if @a is null and @b is null return

if @a+@b> ' '
select * from table_pqs where a> @a and b <@b
else if @a is null
select * from table_pqs where a> @a
else if @b is null
select * from table_pqs where b <@b

go

热点排行
Bad Request.