Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

how to write search condition in sql server

This is a discussion on how to write search condition in sql server within the SQL Server forums, part of the Databases category; Hi friend, I have written a query in oralce for searching ...for example in matrimonial site searching a a bride or groom based on seelct value...now i required to change ...

Go Back   Geeks Talk > Databases > SQL Server
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

SQL Server SQL Server is a Database Management System(DBMS) by Microsoft

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-14-2009
Junior Member
 
Join Date: Apr 2009
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
shree2312 is on a distinguished road
how to write search condition in sql server

Hi friend,

I have written a query in oralce for searching ...for example in matrimonial site searching a a bride or groom based on seelct value...now i required to change the query in sql server...can anybody help...
the code i have written in oracle

procedure Get_viewOrders(reqno in varchar2,reqdate in varchar2,employeename in varchar2)
As
v_qry varchar2(10000);
begin
v_qry:='select tr.requestno,us.firstname||' ' ' '||,tr.status from travelorders tr,users us where lower(us.id)=lower(tr.id)'
if reqno is not null then
v_qry:=v_qry || 'and tr.requestno=upper(' ' ' || reqno || ' ' ')'
end if;
if requestdate is not null then
v_qry:=v_qry || 'and to_date(tr.requestdate,' 'dd\mm\yyyy' ')=to_date(' ' ' ||reqdate|| ' ' ',' ' dd/mm/yyyy' ')'
end if
end Get_viewOrders


thanks
shree

Last edited by shree2312; 06-14-2009 at 04:37 AM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-14-2009
Junior Member
 
Join Date: Apr 2009
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
shree2312 is on a distinguished road
Re: how to write search condition in sql server

and i tried to write the query as shown below

ALTER procedure [dbo].[search_Improved](@firstname varchar(50)=null)
AS
BEGIN
declare @sql nvarchar(4000)
select @sql='select *from EmpDetails where 1=1'
if @firstname is not null
select @sql=@sql+' and fname=@firstname'
END

it returns 0... didnt find the solution
Reply With Quote
Reply

  Geeks Talk > Databases > SQL Server

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Read and write images in vb.net from a database using SQL Server solvequeries VB.NET 2 06-20-2009 04:31 AM
What is the race condition? ABSMITH OOPS 5 10-16-2008 10:10 AM
Where Condition krishnaindia2007 Oracle 3 11-30-2007 01:54 AM
Using LIKE operator in multiple condition Sant_parkash SQL 4 11-29-2007 02:47 AM
Test Condition reks_209 Testing Templates 3 09-14-2007 04:18 AM


All times are GMT -4. The time now is 08:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved