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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Using like statement and function

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2009-10-20 : 12:31:31
I need select claim number from a claim table.
The claim number is combined date and sequence number.
For example in claim number 20080315003, 20080315 is date part, 003 is sequence number.
I wrote a function GetClaimNoDate to return date part as 20080315 or 20080401, etc.
How to use code to select all claim number using GetClaimNoDate and like statement for all claim number?

I code below but never work

select * from claim where claimno like 'GetClaimNoDate%'

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-20 : 12:51:23
why do you even need like statement if you want all claim numbers? you just do select * from claim. but you can do this --> select * from claim where claimno like GetClaimNoDate + '%'. but even that will not work because your function brings back the whole claimnodate.
is there a paramater being sent in that you need to do select * like ? what are you trying to do sir.

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-20 : 14:03:21
does GetClaimNoDate return a single value? if yes you could just use

select * from claim where claimno like dbo.GetClaimNoDate() + '%'
Go to Top of Page
   

- Advertisement -