在SQL server2000下 用下面查询,thistitle为查询字段,test为表 SELECT *, (CASE isnumeric(thistitle) WHEN 1 THEN thistitle WHEN 0 THEN 0 END) AS myReturn FROM test或在库建立用户自定义函数: CREATE FUNCTION dbo.[Gaa] (@chr varchar(100)) RETURNS varchar(100) AS BEGIN declare @tempInt varchar(100) set @tempInt =0 if (isnumeric(@chr)=1) set @tempInt =@chr return @tempInt END 使用以下查询: select *,dbo.Gaa(thistitle) AS myReturn
select * from dd
用下面查询,thistitle为查询字段,test为表
SELECT *, (CASE isnumeric(thistitle) WHEN 1 THEN thistitle WHEN 0 THEN 0 END)
AS myReturn
FROM test或在库建立用户自定义函数:
CREATE FUNCTION dbo.[Gaa] (@chr varchar(100))
RETURNS varchar(100) AS
BEGIN
declare @tempInt varchar(100)
set @tempInt =0
if (isnumeric(@chr)=1)
set @tempInt =@chr
return @tempInt
END
使用以下查询:
select *,dbo.Gaa(thistitle) AS myReturn