日期:2014-05-17 浏览次数:20444 次
USE [LY]
GO
/****** 对象: Table [dbo].[Table1] 脚本日期: 06/20/2013 17:53:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table1](
[id] [int] NULL,
[name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[flag] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
USE [LY]
GO
/****** 对象: Table [dbo].[Table2] 脚本日期: 06/20/2013 17:53:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Table2](
[columnIda] [int] NULL,
[value1] [decimal](18, 2) NULL
) ON [PRIMARY]
select (cast(Table2.value1 as nvarchar(10)) + '/'+ a.flag) as col from Table2 left join (
select cast( replace(parseName(replace( replace(name,'.','-'),',','.'),1),'-','.') as decimal(18,2)) as id1,
cast( replace (parseName(replace(replace(name,'.','-'),',','.'),2),'-','.') as decimal(18,0)) as id2,
flag from table1
)a on
Table2.value1 >= a.id2
and Table2.value1 <= a.id1
--结果
--4.14/1
--5.00/2
--25.11/4
--14.20/3