/*
   SQL Server 2008 Script
   Action: Insert Yuan, Euro, and Tether into dbo.Currency table.
   Checks for duplicates before inserting.
*/

/* ------------------------------------------------------ */
/* 1. Euro (یورو) - Check if ID 2 exists, if not, Insert  */
/* ------------------------------------------------------ */
IF NOT EXISTS (SELECT * FROM dbo.Currency WHERE CurrencyID = 2)
BEGIN
    INSERT INTO dbo.Currency (CurrencyID, Title, Title_En, ExchangeUnit, PrecisionCount, PrecisionName, PrecisionName_En, Version)
    VALUES (2, N'یورو', N'Euro', 1, 2, N'سنت', N'Cent', 0);
    PRINT 'Result: Euro (ID 2) added.';
END
ELSE
BEGIN
    PRINT 'Result: Euro (ID 2) already exists.';
END

/* ------------------------------------------------------ */
/* 2. Chinese Yuan (یوان) - Assigning ID 6                */
/* ------------------------------------------------------ */
IF NOT EXISTS (SELECT * FROM dbo.Currency WHERE CurrencyID = 6)
BEGIN
    INSERT INTO dbo.Currency (CurrencyID, Title, Title_En, ExchangeUnit, PrecisionCount, PrecisionName, PrecisionName_En, Version)
    VALUES (6, N'یوان چین', N'Chinese Yuan', 1, 2, N'فن', N'Fen', 0);
    PRINT 'Result: Yuan (ID 6) added.';
END
ELSE
BEGIN
    PRINT 'Result: Yuan (ID 6) already exists.';
END

/* ------------------------------------------------------ */
/* 3. Tether (تتر) - Assigning ID 7                       */
/* ------------------------------------------------------ */
IF NOT EXISTS (SELECT * FROM dbo.Currency WHERE CurrencyID = 7)
BEGIN
    INSERT INTO dbo.Currency (CurrencyID, Title, Title_En, ExchangeUnit, PrecisionCount, PrecisionName, PrecisionName_En, Version)
    VALUES (7, N'تتر', N'Tether', 1, 2, N'سنت', N'Cent', 0);
    PRINT 'Result: Tether (ID 7) added.';
END
ELSE
BEGIN
    PRINT 'Result: Tether (ID 7) already exists.';
END
/* ------------------------------------------------------ */
/* 4. Swedish Krona (کرون سوئد) - Assigning ID 8          */
/* Note: Subunit is "Öre" (اور)                          */
/* ------------------------------------------------------ */
IF NOT EXISTS (SELECT * FROM dbo.Currency WHERE CurrencyID = 8)
BEGIN
    INSERT INTO dbo.Currency (CurrencyID, Title, Title_En, ExchangeUnit, PrecisionCount, PrecisionName, PrecisionName_En, Version)
    VALUES (8, N'کرون سوئد', N'Swedish Krona', 1, 2, N'اور', N'Ore', 0);
    PRINT 'Result: Krona (ID 8) added.';
END
ELSE
BEGIN
    PRINT 'Result: Krona (ID 8) already exists.';
END

GO