关于select column_xxx into tabel_xxxx生成表的问题

cftzh 2010-07-02 10:48:42
select column_xxx into tabel_xxxx
column_xxx 肯定是要通过select from等语句查出来的,只是写法上我这么写提示 into那有错误,请问该这么写
...全文
57 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
brownhwy 2010-07-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sql_hhy 的回复:]
SQL code
select column_xxx into tabel_xxxx --这个表是不存在的,否则会报错
from tb--这个表是现有的
where 1<1--加上这个条件只复制表结构,不复制数据
[/Quote]
我觉得这个说得比较清楚了,你可能是没有后面的from tb吧?
select column_xxx into table_xxx本身就是错误的。
cftzh 2010-07-02
  • 打赏
  • 举报
回复
恩,是这意思,问题是我用原来的语句可以查询出数据,但把select into一加进去就报错,

Msg 1038, Level 15, State 5, Line 4
缺少对象或列名,或者对象或列名为空。对于 SELECT INTO 语句,请确保每列均具有名称。对于其他语句,请查找空的别名。不允许使用定义为 "" 或 [] 的别名。请添加名称或单个空格作为别名。


这个是什么意思,我的所有列 没有空的别名,只是有的列没有定义别名,难道这也是错
z812183667 2010-07-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sql_hhy 的回复:]
SQL code
select column_xxx into tabel_xxxx --这个表是不存在的,否则会报错
from tb--这个表是现有的
where 1<1--加上这个条件只复制表结构,不复制数据
[/Quote]
学习了!
SQL_Hhy 2010-07-02
  • 打赏
  • 举报
回复
select column_xxx into tabel_xxxx --这个表是不存在的,否则会报错
from tb--这个表是现有的
where 1<1--加上这个条件只复制表结构,不复制数据
albert_sky 2010-07-02
  • 打赏
  • 举报
回复

USE AdventureWorks;
GO
SELECT c.FirstName, c.LastName, e.Title, a.AddressLine1, a.City, sp.Name AS [State/Province], a.PostalCode
INTO dbo.EmployeeAddresses
FROM Person.Contact AS c
JOIN HumanResources.Employee AS e ON e.ContactID = c.ContactID
JOIN HumanResources.EmployeeAddress AS ea ON ea.EmployeeID = e.EmployeeID
JOIN Person.Address AS a on a.AddressID = ea.AddressID
JOIN Person.StateProvince as sp ON sp.StateProvinceID = a.StateProvinceID;
GO



还是把你的SQL语句贴出来看看吧

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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