当前位置: 代码迷 >> Sql Server >> 有关sql的有关问题
  详细解决方案

有关sql的有关问题

热度:34   发布时间:2016-04-27 17:49:49.0
有关sql的问题
数据库表:
CREATE   TABLE   [dbo].[dresstable](
[id]   [int]   IDENTITY(1,1)   NOT   NULL,
[x_dress]   [float]   NULL,
[y_dress]   [float]   NULL,
  CONSTRAINT   [PK_dresstable]   PRIMARY   KEY   CLUSTERED  
(
[id]   ASC
)WITH   (IGNORE_DUP_KEY   =   OFF)   ON   [PRIMARY]
)   ON   [PRIMARY]

insert   into     dresstable   values   ( '152.23265 ', '-89.300025 ')
insert   into     dresstable   values   ( '658.52 ', '9.300025 ')
insert   into     dresstable   values   ( '156.54265 ', '-8.025 ')
insert   into     dresstable   values   ( '15.265 ', '89.025 ')


给出一个地点坐标A,比如(35.268,-23.24),想在表里找出离地点A最近的那条数据id

------解决方案--------------------
我顶!!
------解决方案--------------------
alter procedure GetShortest
(
@x decimal(10,6),
@y decimal(10,6)
)
as
select top 1 * from dresstable order by ([email protected])*([email protected])+([email protected])*([email protected])


运行它时:
execute GetShortest 35.268,-23.24
  相关解决方案