Showing posts with label phone. Show all posts
Showing posts with label phone. Show all posts

Monday, March 26, 2012

MultiRow select to SingleRow output?

Here is what I want to do.

I have a customer table with say id, firstname, lastname. I also have another table called phone number that contains multiple phone numbers based on the customer id (id, customerid, phonenumber).

Ok I want to output a record like this

firstname, lastname, phone1, phone2, phone3

I need one record per customer with as many phone numbers as they may have, I could always limit the numbers to 3 or better yet return a null if there are less then the predefined number of phone numbers.

If I try a simple join I get multiline output which is no good for me.

SELECT firstname, lastname, phonenumber
FROM customer, phone
WHERE phone.customerid = customer.id

Thanks.---------------
create function dbo.PhoneString(@.customerid int)
returns varchar(500)
as
begin
declare @.PhoneString varchar(500)

set @.PhoneString = ''

select @.PhoneString = @.PhoneString + phonenumber + ', '
from PhoneNumberTable
where customerid = @.customerid

set @.PhoneString = left(@.PhonesString, len(@.PhoneString)-1)

return @.PhoneString
end
---------------
select firstname, lastname, dbo.PhoneString(ID) from customers

Wednesday, March 7, 2012

Multiple Sort Order Specification in EDB database

Hi,

I am using the EDB as a database in smart phone applications.I can able to mount the database , create the tables , write the records into the tables and read from the table with single sort order specification.But if i am using more than one sort order specification seek database is throwing an error message "The drive cannot locate a specific area or track on the disk".

I created one table named as Icon with more than one sort order specification.In this table i am giving pageid and iconid as sort order specifications. While saving the data into the database i am opening the database with pageid sort order and storing into the table.while reading from the database i am opening the database with iconid as sortorder.So here while seeking the database the above error is displaying.And i tried to read the data from the table by using pagid as sortorder speicification.It is working fine.I am applying the 3 sort order specifications for another table named as contentTable. but it is working fine with 3 sort order specifications.I had done the samething for icon table .But no use.Please help me regarding this.

Thanks in Advance,

Thanks & Regards,

Prasanna Kumar

Moving to Sql Server compact edition forum where it has got better chances of being answered.

-Thanks,

Mohit