How can i prepare grant staement with 2 files ?

---file1 ( tables

A
B
C
D
E
F
...
...
Z

---file2

Joe
Bob
Mary
Sally
Fred
Elmer
David

All i want is

grant select on TABLE A to user Joe
grant select on TABLE B to user Joe
grant select on TABLE C to user Joe 
grant select on TABLE D to user Joe 
grant select on TABLE E to user Joe
....
grant select on TABLE Z to user Joe 
grant select on TABLE A to user Bob
grant select on TABLE B to user Bob
grant select on TABLE C to user Bob
grant select on TABLE D to user Bob
....
grant select on TABLE Z to user Bob

It has to go till number users given in file 2 ....Can some one help ?

The following seems to do what you want pretty simply:

awk '
FNR == NR {
	t[nt = NR] = $0
	next
}
{	for(i = 1; i <= nt; i++)
		print "grant select on TABLE", t, "to user", $0
}' file1 file2

producing the output (greatly abbreviated):

grant select on TABLE A to user Joe
grant select on TABLE B to user Joe
grant select on TABLE C to user Joe
grant select on TABLE D to user Joe
grant select on TABLE E to user Joe
grant select on TABLE F to user Joe
grant select on TABLE ... to user Joe
grant select on TABLE ... to user Joe
grant select on TABLE Z to user Joe
grant select on TABLE A to user Bob
... abbreviated ...
grant select on TABLE Z to user Elmer
grant select on TABLE A to user David
grant select on TABLE B to user David
grant select on TABLE C to user David
grant select on TABLE D to user David
grant select on TABLE E to user David
grant select on TABLE F to user David
grant select on TABLE ... to user David
grant select on TABLE ... to user David
grant select on TABLE Z to user David

with the sample input files you provided.

If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk .