Question: I want to read a csv file where header row starts from specific column name i.e “name”

The CSV file format looks like this:

```
v3,vf,gf--Not a Header row 1
v1,c,z1,e--Not a Hera  row 2
name,q1,q2,q3- Header Row- row 3-because name is here
a,0,1,2-Data

```

I want to read where “name” column exists - so I want to skip the first 2 rows, but we don't know before “name” how many row will come it may 2 or 3 or n

Answer: 
Neither `RAND` or `NEWID` can be directly referenced in a function.

You can indirectly reference these via a view though. So you can use

```
CREATE VIEW dbo.RandomInt
AS
  SELECT CAST(CRYPT_GEN_RANDOM(4) AS INT) AS Number

GO

CREATE FUNCTION U228_TEST_USER_1.mask_firstn ()
RETURNS VARCHAR(15)
AS
  BEGIN
      DECLARE @OneToFive TINYINT = (SELECT 1 + ABS(Number % 5) FROM dbo.RandomInt);

      RETURN
        (SELECT CHOOSE(@OneToFive, 'JAMES', 'JOHN', 'ROBERT', 'MICHAEL', 'MARY'))
  END 

```

Scalar UDFs should generally be avoided but in this case it will probably be fine - inlining it makes it more likely that the result will only be evaluated once rather than per row - which is not desirable in the case of random data generation.
You can't use NEWID() in a function, see [this](https://stackoverflow.com/questions/772517/newid-inside-sql-server-function) for a couple workarounds.