Mega Code Archive

 
Categories / MSSQL Tutorial / System Settings
 

Use OBJECT_ID in insert statement

3>  CREATE TABLE mytable 4> ( 5>     int_val        int, 6>     smallint_val   smallint, 7>     numeric_val    numeric(8, 2), 8>     tiny_const     tinyint, 9>     float_val      float, 10>     date_val       datetime, 11>     char_strng     char(10) 12> ) 13> GO 1> 2> DECLARE @myvar1 numeric(8, 2) 3> SELECT @myvar1=65.45 4> 5> INSERT mytable (int_val, smallint_val, numeric_val, tiny_const, 6>     float_val, date_val, char_strng) 7> VALUES 8> (OBJECT_ID('mytable'), @@spid, @myvar1 / 10.0, 5, 9> SQRT(144), GETDATE(), REPLICATE('A', 3) + REPLICATE('B', 3)) 10> GO (1 rows affected) 1> 2> SELECT * FROM mytable 3> GO int_val     smallint_val numeric_val tiny_const float_val                date_val                char_strng ----------- ------------ ----------- ---------- ------------------------ ----------------------- ----------  1019202731           51        6.55          5                       12 2008-08-17 13:19:00.380 AAABBB (1 rows affected) 1> 2> 3> drop table myTable; 4> GO 1> 2>