Insert into with EXEC : EXEC « Transact SQL « SQL Server / T-SQL Tutorial






4>    CREATE TABLE #VersionTable(
5>       [Index] int PRIMARY KEY,
6>       Name varchar(30),
7>       Internal_Value int,
8>       Character_Value varchar(250)
9>    )
10>    GO
1>
2>    INSERT INTO #VersionTable
3>    EXEC master..xp_msver
4>
5>    DECLARE @Version int
6>
7>    SELECT @Version = (SELECT Internal_Value
8>                                 FROM #VersionTable
9>                                 WHERE Name = 'ProductVersion')
10>    IF (@Version) >= 524288
11>       PRINT 'Running SS2K Beta 2 or Later'
12>    ELSE
13>       IF @Version >= 458752
14>          PRINT 'Running 7.0 RTM or Later'
15>       ELSE
16>          PRINT 'Running Pre 7.0 RTM Version'
17> GO

(20 rows affected)

(20 rows affected)
Running SS2K Beta 2 or Later
1>    DROP TABLE #VersionTable
2> GO








20.19.EXEC
20.19.1.The syntax of the EXEC statement
20.19.2.EXECUTE AS
20.19.3.Dynamic Selects
20.19.4.A stored procedure with dynamic execution by using EXEC
20.19.5.Sending Variable Information to an EXEC() Call
20.19.6.Switch database in EXEC
20.19.7.Statement Limit
20.19.8.Parse exception in another level of scope: Exception in EXEC
20.19.9.Execute a dynamic statement and return the result with OUTPUT
20.19.10.Use more than one sql statement in EXEC
20.19.11.Insert into with EXEC
20.19.12.Using EXEC () to Execute a Dynamic TOP n Query