日期:2014-05-19  浏览次数:20494 次

如何获取空格以前的数据
比如字段是
123     1323
asdas   asd
那么我想得到结果是
123
asdas

------解决方案--------------------
写反了.

select left(字段 , charindex( ' ' , 字段) - 1) from tb

------解决方案--------------------
先要drop掉test表.
ALTER PROCEDURE [dbo].[testProc]
AS
BEGIN
if exists(select 1 from sysobjects where xtype= 'U ' and name= 'test ')
drop table test
declare @test int;
select count(*) as c into test from table2;
print @test

END
------解决方案--------------------
select a,left(a,charindex( ' ',a)) FROM test