h1

Functia Pi si produsul a 2numere in mssql

March 2, 2010

–PI -intoarce nr.pi
SELECT PI()

DECLARE @nr1 int;
DECLARE @nr2 int;
DECLARE @nr3 int; –result to be displayed

SET @nr1 = 2;
SET @nr2 = 3;

SET @nr3 = @nr1*@nr2; — obs. se face set si la variabilele rezultat —atentie!!!

–SELECT ‘Rezultat:’ +@nr1*@nr2
— rezultatul este de tip varchar deci trebuie neaparat facut la variabila nr3 conversia din int in varchar !!! (atentie conversie la afisare rezultate in mssql!!!)
PRINT ‘Rezultatul este’ + CAST(@nr3 AS VARCHAR(10));

GO

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: