如何使用SQL Server中的select查询创build表?
我尝试使用SYS查询制作50-100个表
SELECT windows_release, windows_service_pack_level, windows_sku, os_language_version FROM sys.dm_os_windows_info OPTION (RECOMPILE); -- DEĞİŞİRSE INSERT ETSIN AYNI ISE DEĞİŞMESİN -- Gives you major OS version, Service Pack, Edition, and language info for the operating system -- SQL Server Services information (SQL Server 2008 R2 SP1 or greater) SELECT servicename, startup_type_desc, status_desc, last_startup_time, service_account, is_clustered, cluster_nodename FROM sys.dm_server_services OPTION (RECOMPILE); -- Hardware information from SQL Server 2008 -- (Cannot distinguish between HT and multi-core) SELECT cpu_count AS [Logical CPU Count], hyperthread_ratio AS [Hyperthread Ratio], cpu_count/hyperthread_ratio AS [Physical CPU Count], physical_memory_in_bytes/1048576 AS [Physical Memory (MB)], sqlserver_start_time --, affinity_type_desc -- (affinity_type_desc is only in 2008 R2) FROM sys.dm_os_sys_info OPTION (RECOMPILE);
如何从SYS表查询结果创build表?
我知道这是一个古老的问题,但我发现这样的事情,这是完美的工作:
CREATE TABLE resultTable AS(SELECT gdb.song AS vroar, gdb.song_description AS vdescription FROM googleDB gdb WHERE gdb.song_id = 'KP');
句法:
CREATE TABLE <ResultTable_Name> AS(SELECT <actual_table_property1> AS <alias1>, <actual_table_property2> AS <alias2> FROM <actual_table_name> WHERE <actual_table_property> = '<value>');
我希望这可以帮助别人。
select <column list> into <table name> from <source> where <whereclause>
select <column list> into <dest. table> from <source table>;
你可以这样做。
SELECT windows_release, windows_service_pack_level, windows_sku, os_language_version into new_table_name FROM sys.dm_os_windows_info OPTION (RECOMPILE);