一条 SELECT 语句,高手进来看看 我有一表,结构入下: UID(非自增) NAME现在我想写一条 SELECT 语句,查询结果如下 ID(自动生成的自增列) UID NAME请问能不能够实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select ID=identity(int,1,1),* into # from tb 临时表select id=identity(int,1,1),uid,name into #t from tselect * from #t alter table 表名 add 列名 int identity( 1,1) select id=Identity(int,1,1), * into 临时表 from 表 还有,上面的语句在存储过程中,用 EXEC(select id=Identity(int,1,1), * into 临时表 from 表)执行后,怎么不能用了? 难道作用域只在 EXEC 内? From 《Sql server 联机丛书》:IDENTITY 函数“只用在带有 INTO table 子句的 SELECT 语句中,以将标识列插入到新表中。” 噢!是这样,忘了,不好意思,楼上说得对select id=Identity(int,1,1), * into 新表 from 表 我现在的 select id=Identity(int,1,1), * into 新表 from 表 语句是在 存储过程里 拼出来,然后放在 EXEC() 里执行。是不是 临时表的作用域就只在 EXEC() 内了呢?有啥办法解决嘛? select id=Identity(int,1,1), * into 新表 from 表 这条语句中生成了一个新表,不是临时表。 如何用sql语句中止sql脚本的执行 select查询语句 有点小难,想了一天 多表关联的sql语句 关于数据库加密的未公开函数pwdencrypt及pwdcompare的迷惑!!请高手解决! sqlserver 2008 r2 客户端的代码提示功能无效,怎么修复? 请问如何用一条查询语句 查2张表并且排序? 自增字段连续问题 SOS 求SQL 2005 将2个表的数据同时查询出来。 一台电脑同时安sql 2000,sql 2005 会好好的工作吗? 求教:关于text字段的搜索和替换问题!
select * from #t
)执行后,怎么不能用了? 难道作用域只在 EXEC 内?
select id=Identity(int,1,1), * into 新表 from 表
语句是在 存储过程里 拼出来,然后放在 EXEC() 里执行。是不是 临时表的作用域就只在 EXEC() 内了呢?
有啥办法解决嘛?
这条语句中生成了一个新表,不是临时表。