0

this is my function:

create function ReservationByClient (@reservation_ID int)
returns table
as

    return(
    select 
    c.client_name,
    c.client_surname,
    c.client_passport,
    r.aptID,
    r.start_date,
    r.end_date,
    r.confirmation
    from tblClient c 
    inner join  tblReservation r on r.client_ID=c.client_ID
    where r.reservation_ID=@reservation_ID)

when invoked with:

select * from dbo.ReservationByClient (602)

it returns only column names and no values in it even there are existing records in both tables, eg. there are three reservations for the same client.

one more question: can i get results only for confirmed reservations (field confirmed is bit type)

thanks

Taryn
  • 242,637
  • 56
  • 362
  • 405
  • 2
    You're going to need to post some data from your tables, I think. And your question says "eg there are three reservations for the same client," but the parameter to your function is taking a *reservation* id, so part of me wonders if there's something confused there.. (hence the need to see some data). – David W Feb 22 '13 at 21:16
  • Maybe you have some inconsistency in schemes? – Hamlet Hakobyan Feb 22 '13 at 21:25
  • table tblReservations has folowing fields: reservation_ID (int), aptID (int), client_ID (int), start_date (datetime), end_date (datetime), details (nvarchar(max)), confirmation (bit) table tblClients has folowing fields: client_id (int), Client_name(nvarchar(50)), client_surname(nvarchar(50)), client_passport (nvarchar(50)) for client_ID=2 there are 3 existing reservations in tblReservation – user2099269 Feb 22 '13 at 21:26
  • Do you have a reservation row with reservation_ID=602? if so, does the client_id on this row exist in the clients table? – engil Feb 22 '13 at 21:41
  • no, that was the problem, i deleted that id, thanks – user2099269 Feb 23 '13 at 09:03

0 Answers0