SQL trig_funcs
SQL
Download (.zip)
use pubs SET NOCOUNT ON go
if ( isnull(object_id('seq_num'),0) > 0) DROP TABLE seq_num go
-- List sine/cosine/tangent for every angle from 0 through 180. -- This solution uses a table of ordered numbers that we can -- select from to produce the desired output.
-- Create the seq_num table CREATE TABLE seq_num (seq_num INT PRIMARY KEY NOT NULL)
-- Populate the seq_num table -- with values from -500 through 500 DECLARE @counter int SELECT @counter= -500 WHILE (@counter <= 500) BEGIN INSERT seq_num VALUES (@counter) SELECT @counter=@counter + 1 END
-- If doing this for real, may as well set FILLFACTOR to 100. -- I wont bother here UPDATE STATISTICS seq_num
-- Now select from seq_num SELECT ANGLE=seq_num * 10, SINE=STR(SIN(seq_num * 10), 7, 4), COSINE=STR(COS(seq_num * 10), 7, 4), TANGENT=STR(TAN(seq_num * 10), 7, 4) FROM seq_num WHERE seq_num BETWEEN 0 AND 18
|