sql 语句问题

lixin546 2009-04-29 10:57:18
declare @table as nvarchar(50)
set @table = 'table' + (select convert(nvarchar(11),getdate(),112))

select * into @table from table

===============================================
消息 102,级别 15,状态 1,第 4 行
'@table' 附近有语法错误。


请问啥原因啊???
...全文
82 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hwg119 2009-04-29
  • 打赏
  • 举报
回复

select * into @table from table
修改成:
exec('select * into ' + @table + ' from [table]')
ljhcy99 2009-04-29
  • 打赏
  • 举报
回复
@table 不是表,只是一个变量。
被变量的名字迷惑了
zzxap 2009-04-29
  • 打赏
  • 举报
回复
select * into ['+@table+'] from table
ws_hgo 2009-04-29
  • 打赏
  • 举报
回复
declare @table as nvarchar(50) 
set @table = 'table' + (select convert(nvarchar(11),getdate(),112))

select @table into 你要插入的表 from [table]
ws_hgo 2009-04-29
  • 打赏
  • 举报
回复
select * into @table from table -->这个地方是变量不是表
ws_hgo 2009-04-29
  • 打赏
  • 举报
回复
[Quote=引用楼主 lixin546 的帖子:]
declare @table as nvarchar(50)
set @table = 'table' + (select convert(nvarchar(11),getdate(),112))

select * into @table from table

===============================================
消息 102,级别 15,状态 1,第 4 行
'@table' 附近有语法错误。


请问啥原因啊???
[/Quote]
肯定错啦

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧