Saturday, February 25, 2012

Please help...how to automatically generate names in the table?

Hello! every one, I am a student studying DB Admin and my professor gave us an assignment which I couldn' t quite get it. Could any one offer a hand?

the assignment is to generate random number with random name(female or male) the names are all from an imported table(such as one from Northwind).

He said first step was to decide on sex, then get the "count" of names, and then decide on ranmdom number between 1 and the count....

any way I am really confused and couldn't know how to start it.please help!

If your intention is to fetch the random name from the given table the followint query will do..

Code Snippet

Declare @.Sex as Varchar(10);

Set @.Sex='M'

Select Top 1 FirstName + ', ' + LastNamefrom Employees Where Sex=@.Sex Order By newid()

No comments:

Post a Comment