materialise temp table (from SELECT INTO)
I pick up LOTS of legacy code with SELECT INTO statements.
sometimes they are into temp tables but also in physical tables.
It would be great to be able to highlight the statement in the SQL and right-click and choose to automatically convert it into a TRUNCATE + INSERT INTO (whilst running the CREATE TABLE statement for me)
for example:
/This is the statement I start off with/
SELECT TOP 10 *
INTO dbo.example_table
FROM sys.objects
/SQL prompt pops up with dialog box to choose the table name and creates the table for me/
CREATE TABLE [dbo].[exampletable]
(
[name] [sys].[sysname] NOT NULL,
[object_id] [int] NOT NULL,
[principal_id] [int] NULL,
[schema_id] [int] NOT NULL,
[parentobjectid] [int] NOT NULL,
[type] [char] (2) COLLATE Latin1GeneralCIASKSWS NULL,
[typedesc] [nvarchar] (60) COLLATE Latin1GeneralCIASKSWS NULL,
[create_date] [datetime] NOT NULL,
[modify_date] [datetime] NOT NULL,
[ismsshipped] [bit] NOT NULL,
[is_published] [bit] NOT NULL,
[isschemapublished] [bit] NOT NULL
) ON [PRIMARY]
GO
/SQL Prompt then replaces the SELECT INTO with the following code/
TRUNCATE TABLE dbo.example_table
INSERT INTO dbo.exampletable (name, objectid, principalid, schemaid, parentobjectid, type, typedesc, createdate, modifydate, ismsshipped, ispublished, isschemapublished)
SELECT TOP 10 *
FROM sys.objects