Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jaimin
Starting Member
21 Posts |
Posted - 2007-10-30 : 08:17:01
|
| hi,i am new to this.in my aspx page, i am having a dropdown which has two valueNameEmpIDif user clicks on name from drop down, user has enter the name of employee in a textbox. And if user clicks on EmpID, he has to enter the employee ID in textbox.Based on selection the data will be displayed in grid view.In my database, i have a table called EmpInfo, which has three fields - EmpName, EmpID and State. can anybody help me in writing a stored procedure for this??ThanksJaimin |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-10-30 : 08:21:27
|
| create proc s_Get_EmpInfo@Data varchar(100) ,@Type varchar(20) -- 'ID', 'Name'asselect EmpName, EmpID, Statefrom EmpInfowhere (@Data = EmpID and @Type = 'ID')or (@Data = EmpName and @Type = 'Name')go==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2007-11-02 : 04:51:40
|
| make two stored procedures one for name, one for id this just because of consideration of performance issuesmake a if else statement at c# coding if id selected then procedure for id will called or if name selected then procedure for name is calledcreate procedure fetch_data @name varchar(12)asbeginselect "columnname to be fetch" from tablenamewhere name="col_name column that contains the name list"endcall execute fetch_data in name part of if else statementRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-11-02 : 05:15:14
|
| You could just have one text box called, say, FIND and let the user type ID, name, Phone number, etc. in there ... and then have an SProc that uses a "broad" query to find matches - ranking those with exact match higher than partial match and, presumably, and Employee ID match higher than a ZipCode ... depends on the type of user I suppose.Kristen |
 |
|
|
|
|
|
|
|