Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to move not like string into table??
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

5 Posts

Posted - 12/04/2012 :  22:14:42  Show Profile  Reply with Quote
Say I have a sql query like this:

Declare @table1 TABLE(id INT, field1 VARCHAR(100))
SELECT 1,'Apple Juice'
UNION ALL SELECT 2,'Orange Juice'
UNION ALL SELECT 3,'Coffee and tea'
UNION ALL SELECT 4,'randam text...'
UNION ALL SELECT 5,'I eat an apple everyday'

Select * from @table1
	where field1 not like '%apple%' and field1 not like '%orange%'

Now I want to put the hard code values "apple" and "orange" into a table so that I can update it without modifying SP or Query string in asp file.

How can I do it?


In (Som, Ni, Yak)

17689 Posts

Posted - 12/04/2012 :  22:23:24  Show Profile  Reply with Quote
how about create a view for it ?

Time is always against us

Go to Top of Page

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/05/2012 :  06:58:42  Show Profile  Reply with Quote
You can put the search terms into a table and join to that table - but you will always be querying for the terms that table. Is that what you really want?

Do you get the search terms from the side? If you are, are you sending those search terms to a stored proc? Give a bit more detail on what you are trying to do.
Go to Top of Page

Flowing Fount of Yak Knowledge

United Kingdom
3385 Posts

Posted - 12/05/2012 :  08:20:56  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
create table SearchTerms
s varchar(20)
insert SearchTerms select 'apple'
insert SearchTerms select 'orange'
select t1.*
from @table1 t1
left join SearchTerms s
on t1.field1 like '%' + s.s + '%'
where s.s is null

Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Starting Member

5 Posts

Posted - 12/05/2012 :  21:31:57  Show Profile  Reply with Quote
Originally posted by sunitabeck

In fact I am working on a classic asp file... the query string is in the file and one user want to add some filters to the result (not parameter).

The user may update filter terms later on so I am looking for some shortcuts to do it.

Originally posted by nigelrivett

thx, I will try it :)

Edited by - yeung_lcd on 12/05/2012 21:32:45
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000