您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

T-SQL插入表中,而不必指定每一列

T-SQL插入表中,而不必指定每一列

您实际上可以很容易地做到这一点:

-- Select everything into temp table
Select * Into 
    #tmpBigTable
    From [YourBigTable]

-- Drop the Primary Key Column from the temp table  
Alter Table #tmpBigTable Drop Column [PrimaryKeyColumn]

-- Insert that into your other big table
Insert Into [YourOtherBigTable]
    Select * From #tmpBigTable

-- Drop the temp table you created
Drop Table #tmpBigTable

只要您在“ YourOtherBigTable”中具有“身份插入”且列完全相同,就可以了。

SQLServer 2022/1/1 18:52:35 有540人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶