GremlinSA
August 11th, 2008, 05:59 AM
Okay you Sql Fundi's .. i have another question to ask...
We need a Search function to return all records matching the search string.. One catch.. the search is run every time one character is entered, and a autoComplete function is done, however ALL matching results are shown ..
select ConsumerSurname +', ' +ConsumerName + ' [' + AccountNo + ']' ConsumerName ,
ConsumerSurname,
ConsumerID,
AccountNo
into #TmpCust001
FROM [CF3_Consumer]
WHERE ConsumerSurname like '%' + @SearchStr +'%'
ORDER BY ConsumerSurname
if Object_ID('TempDb..#TmpCust001') is not NULL --Then the customer/s not found at all
begin
if exists(select * from #TmpCust001)
begin
select * from #TmpCust001
drop table [dbo].[#TmpCust001]
end else
'....... etc
However this will only return records where the surname matches, and not the name.. if I use the folowing for my where clause WHERE ConsumerSurname like '%' + @SearchStr +'%' or ConsumerName like '%' + @SearchStr +'%'The autocomplete function does not work on names ..
So i was looking into doing select ConsumerSurname +', ' +ConsumerName + ' [' + AccountNo + ']' ConsumerName ,
ConsumerSurname,
ConsumerID,
AccountNo
into #TmpCust001
FROM [CF3_Consumer]
WHERE ConsumerSurname like '%' + @SearchStr +'%'
ORDER BY ConsumerSurname
select ConsumerName +', ' +ConsumerSurName + ' [' + AccountNo + ']' ConsumerName ,
ConsumerSurname,
ConsumerID,
AccountNo
into #TmpCust001
FROM [CF3_Consumer]
WHERE Consumername like '%' + @SearchStr +'%'
ORDER BY ConsumernameHowever the second Into #tmpCust001 is not accepted, so how can i add a second Select into a Temporary table .. ????
Thanks...
Gremmy..
We need a Search function to return all records matching the search string.. One catch.. the search is run every time one character is entered, and a autoComplete function is done, however ALL matching results are shown ..
select ConsumerSurname +', ' +ConsumerName + ' [' + AccountNo + ']' ConsumerName ,
ConsumerSurname,
ConsumerID,
AccountNo
into #TmpCust001
FROM [CF3_Consumer]
WHERE ConsumerSurname like '%' + @SearchStr +'%'
ORDER BY ConsumerSurname
if Object_ID('TempDb..#TmpCust001') is not NULL --Then the customer/s not found at all
begin
if exists(select * from #TmpCust001)
begin
select * from #TmpCust001
drop table [dbo].[#TmpCust001]
end else
'....... etc
However this will only return records where the surname matches, and not the name.. if I use the folowing for my where clause WHERE ConsumerSurname like '%' + @SearchStr +'%' or ConsumerName like '%' + @SearchStr +'%'The autocomplete function does not work on names ..
So i was looking into doing select ConsumerSurname +', ' +ConsumerName + ' [' + AccountNo + ']' ConsumerName ,
ConsumerSurname,
ConsumerID,
AccountNo
into #TmpCust001
FROM [CF3_Consumer]
WHERE ConsumerSurname like '%' + @SearchStr +'%'
ORDER BY ConsumerSurname
select ConsumerName +', ' +ConsumerSurName + ' [' + AccountNo + ']' ConsumerName ,
ConsumerSurname,
ConsumerID,
AccountNo
into #TmpCust001
FROM [CF3_Consumer]
WHERE Consumername like '%' + @SearchStr +'%'
ORDER BY ConsumernameHowever the second Into #tmpCust001 is not accepted, so how can i add a second Select into a Temporary table .. ????
Thanks...
Gremmy..