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 |
|
hyder.inam
Starting Member
1 Post |
Posted - 2011-10-07 : 07:22:36
|
hi i want to know some thing about Tsqlthis query works fine on oracle but i want to make it work on sql serverSELECT * from Table_nameWhere id = Nvl(some_Parameter, id)AND name = Nvl(Parameter_name, Name)What is the function used instead of nvl in sql serverabove query work like if we want to search on id or name or both the query will show required result  |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-07 : 07:24:51
|
| [code]SELECT * from Table_nameWhere id = coalesce(some_Parameter, id)AND name = coalesce(Parameter_name, Name)another waySELECT * from Table_nameWhere (id = some_Parameter or some_Parameter is null)AND (name = Parameter_name or Parameter_name is null)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Cindyaz
Yak Posting Veteran
73 Posts |
Posted - 2011-10-07 : 11:04:36
|
| also check for isnull() function.[url]http://msdn.microsoft.com/en-us/library/ms184325.aspx [/url] |
 |
|
|
|
|
|