SQL SERVER – Generate Random Values – SQL in Sixty Seconds #042 – Video

SQL SERVER - Generate Random Values - SQL in Sixty Seconds #042 - Video 60x60 Though it looks simple it is very difficult to generate random numbers which one can’t guess. There are many different ways to generate random values in SQL Server. I have previously blogged about it over here where I have demonstrated five different methods to generate random values in SQL Server.

SQL SERVER – Random Number Generator Script – SQL Query

In this sixty second video we will see a neat trick where we will generate Random value between specified two numbers.

Let us see the same concept in following SQL in Sixty Seconds Video:

[youtube=https://www.youtube.com/watch?v=1d29ka0hHnc]

Related Tips in SQL in Sixty Seconds:

What would you like to see in the next SQL in Sixty Seconds video?

Reference: Pinal Dave (https://blog.sqlauthority.com)

Database, SQL in Sixty Seconds, SQL Scripts, SQL Server Management Studio
Previous Post
SQL SERVER – Fix: Error: 1505 The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name and the index name
Next Post
SQLAuthority News – Delhi Women Safety – 2400th Blog Post – A Milestone

Related Posts

1 Comment. Leave new

  • Dear Pinal,

    I am giving one of example of Sql query which I used in SSRS Report. In below example used few sub queries to achieve result. But few more queries are there where lot of sub queries used(15-20) in same manner. Basically what we want the count of record based on different condition. Because of lot of sub queries used in Sql queries its taking lot of time to execute (Performance issue). Is there are any alternate way to achieve same result within minimum time of execution.Please give valuable suggestion/solution.

    Example:
    SELECT FI.Name,
    (SELECT COUNT(*) FROM FilterIncidentTrans AS FIT
    WHERE FIT.IsPunUnits=1 AND FIT.RecId=FI.RecId) AS [PUN UNITS COUNT],
    (SELECT COUNT(*) FROM FilterIncidentTrans AS FIT
    WHERE FIT.IsREBELUnits=1 AND FIT.RecId=FI.RecId) AS [REBEL UNITS COUNT],
    (SELECT COUNT(*) FROM FilterIncidentTrans AS FIT
    WHERE FIT.IsOtherUnits=1 AND FIT.RecId=FI.RecId) AS [Other UNITS COUNT]
    FROM FilterIncident AS FI
    WHERE FI.StartDate=@StartDate and FI.EndDate=@EndDate

    Reply

Leave a Reply