select *,cast(bin as decimal(10,2)) as bin2 into #tmp2
from MyTable
where convert(varchar(10),[Time],120) between '2009-07-01' and '2009-10-28 23:59:59'
order by bin2 其中bin字段为varchar,不过其值能转换成2位浮点小数。1.如上一个SQL,我想在查询分析器运行的时候查看(打印、调试)#tmp2的数据,有没有办法?2.按照我后面一连串的勉强推测,貌似插入到#tmp2表的数据根本没有经过order by bin2排序,更不知有没有经过where的条件筛选,,,,,,,假若如我推测的话,有否解决办法?
from MyTable
where convert(varchar(10),[Time],120) between '2009-07-01' and '2009-10-28 23:59:59'
order by bin2 其中bin字段为varchar,不过其值能转换成2位浮点小数。1.如上一个SQL,我想在查询分析器运行的时候查看(打印、调试)#tmp2的数据,有没有办法?2.按照我后面一连串的勉强推测,貌似插入到#tmp2表的数据根本没有经过order by bin2排序,更不知有没有经过where的条件筛选,,,,,,,假若如我推测的话,有否解决办法?
(
ID int identity(1,1) primary key,
Bin varchar(10)
)
insert into #tt select 'aa'
insert into #tt select 'bb'
insert into #tt select 'cc'exec ('select * from #tt')
ID Bin
----------- ----------
1 aa
2 bb
3 cc(3 行受影响)
select * from #tmp2 2.
插入到#tmp2表的数据是where的条件筛选过的,也是排序过的。
直接用
SELECT * FROM #T
2
肯定有筛选,肯定有排序
1.#tmp2是一个临时表,而且我不止一个select语句,这个select语句还依赖之前的select语句的筛选结果#tmp的,我只是截取一部分出来。一有2个或以上的select语句,查询分析器的结果就不出现表格了,就出现多少行受影响就完了!
这样的话,有没有办法查看#tmp2的数据?
from MyTable
where convert(varchar(19),[Time],120) between '2009-07-01 00:00:00' and '2009-10-28 23:59:59'
order by cast(bin as decimal(10,2)) select *,cast(bin as decimal(10,2)) as bin2 into #tmp2
from MyTable
where convert(varchar(10),[Time],120) between '2009-07-01' and '2009-10-28'
order by cast(bin as decimal(10,2)) select * from #tmp2 拷贝文本打印.
select * from #tmp2 order by bin2
加一个select
insert into table
select XXX
或者
select XXX
into table from table
的话,就是把select出来的东西插入到表里面,不是读出来