Showing posts with label particular. Show all posts
Showing posts with label particular. Show all posts

Tuesday, March 27, 2012

Basic Full Text search question

Hi

I am just starting to do a full text search on a sql 2000 database. My question is:

If I want to query a table Employee for 1. a particular word in a very large varchar field named "resume" 2 - a boolean field named "willtransfer" and 3. a field that holds the index of another table named "Cities" Cities just holds an index and cityname field of 15 characters.

do I create a fulltext index for all three fields or only the "resume" field since it is the only field that is being searched? What would a query for these 3 fields look like if I am searching for. I have seen no examples that combine multiple fields.

"speaks French" in resume, "true" for "willtransfer " field, and "Miami" in the cities table (there would need to be an inner join on the cityid field in both Employee and City table.

Thanks for any help on this. This is not the tables I am using, but this seemed like an easy example to explain.

smhaig

SELECT e.resume, e.willtransfer, c.cityname FROM Employee e
JOIN City c ON e.cityid = c.cityid
WHERE e.resume LIKE '%FRENCH%'
AND e.willtransfer = True
AND c.CityName = 'MIAMI'

I think maybe you might be looking for something like:

DECLARE @.mystring varchar(50)
SET @.mystring = 'french transfer=true Miami'

SELECT e.resume, e.willtransfer, c.cityname FROM Employee e
JOIN City c ON e.cityid = c.cityid
WHERE @.MyString LIKE '%FRENCH%'
AND @.MyString LIKE '%transfer=True%'
AND @.MyString@. = 'Miami'
AND e.resume LIKE '%FRENCH%'
AND e. willtransfer = 'True'
AND c.cityname = 'Miami'

I'm not sure if you want to concatenate all three fields or not.

Please see above

Adamus

|||

You only put a full text index on the 1 field you filter on the other columns using a standard where clause

i.e.

select employeeId

from employee

join city on employee.cityId = cities.cityId

where willtransfer = 1

and cityname = 'Miami'

and contains (employee.resume,'French')

This would match any resume that contains French you might want to include more complex search like "French NEAR speaks"

Sunday, March 25, 2012

Basic Example of Insert, Update Trigger

Hello, Can someone please show me a basic example of trigger that will
work with two tables in this manner:
1. On INSERT for Table1, copy a particular column's value to another
column in Table2
2. On UPDATE for Table1, copy this particular column's value to
another column in Table2.
The key field for both tables is Invoice# and will always exist in
both tables.
It seems like there are a couple ways to do this, one with just using
a join and the other using the 'Inserted' table. Could someone please
show me the best approach to this solution? I would really be grateful
and name my next born after you.
Thanks in advance,
Buster
On Jun 13, 6:51 am, Buster Coder <dice_respo...@.hotmail.com> wrote:
> Hello, Can someone please show me a basic example of trigger that will
> work with two tables in this manner:
> 1. On INSERT for Table1, copy a particular column's value to another
> column in Table2
> 2. On UPDATE for Table1, copy this particular column's value to
> another column in Table2.
> The key field for both tables is Invoice# and will always exist in
> both tables.
> It seems like there are a couple ways to do this, one with just using
> a join and the other using the 'Inserted' table. Could someone please
> show me the best approach to this solution? I would really be grateful
> and name my next born after you.
> Thanks in advance,
> Buster
I think you require update in table2 in both the cases
CREATE TRIGGER employee_insupd
ON table1
FOR INSERT, UPDATE
AS
UPDATE T2 SET
col2 = a.col1
FROM table2 T2 , inserted a
WHERE T2.invoiceno = a.invoiceno

Basic Example of Insert, Update Trigger

Hello, Can someone please show me a basic example of trigger that will
work with two tables in this manner:
1. On INSERT for Table1, copy a particular column's value to another
column in Table2
2. On UPDATE for Table1, copy this particular column's value to
another column in Table2.
The key field for both tables is Invoice# and will always exist in
both tables.
It seems like there are a couple ways to do this, one with just using
a join and the other using the 'Inserted' table. Could someone please
show me the best approach to this solution? I would really be grateful
and name my next born after you.
Thanks in advance,
BusterOn Jun 13, 6:51 am, Buster Coder <dice_respo...@.hotmail.com> wrote:
> Hello, Can someone please show me a basic example of trigger that will
> work with two tables in this manner:
> 1. On INSERT for Table1, copy a particular column's value to another
> column in Table2
> 2. On UPDATE for Table1, copy this particular column's value to
> another column in Table2.
> The key field for both tables is Invoice# and will always exist in
> both tables.
> It seems like there are a couple ways to do this, one with just using
> a join and the other using the 'Inserted' table. Could someone please
> show me the best approach to this solution? I would really be grateful
> and name my next born after you.
> Thanks in advance,
> Buster
I think you require update in table2 in both the cases
CREATE TRIGGER employee_insupd
ON table1
FOR INSERT, UPDATE
AS
UPDATE T2 SET
col2 = a.col1
FROM table2 T2 , inserted a
WHERE T2.invoiceno = a.invoiceno

Sunday, March 11, 2012

Bad characters in strings

Hi
We have a problem whereby a particular application is writing certain ascii
characters to our table which is causing an issue in another application.
Obviously the solution is to fix the application, but it's taking some time.
In the meantime I'm trying to develop a trigger to fix the data. I have a
table which contains a row for every ascii character which we do not want to
allow, I'm trying to develop a very efficient trigger to remove these bad
ascii characters (on around 7 string columns in 1 table)
Any hints on how to do this?
ThanksUse an INSTEAD OF trigger rather than an AFTER (the default), the INSTEAD OF
will do it before the insert/update occurrs thereby making it more
efficient, if you did it in the AFTER trigger (the default) then you'll be
doing an insert and then a further delete.
Use nested REPLACE to remove the characters, do you have a list of the
characters - are there a lot?
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"..." <...@.nowhere.com> wrote in message
news:O2Joviu5FHA.472@.TK2MSFTNGP15.phx.gbl...
> Hi
> We have a problem whereby a particular application is writing certain
> ascii characters to our table which is causing an issue in another
> application.
> Obviously the solution is to fix the application, but it's taking some
> time. In the meantime I'm trying to develop a trigger to fix the data. I
> have a table which contains a row for every ascii character which we do
> not want to allow, I'm trying to develop a very efficient trigger to
> remove these bad ascii characters (on around 7 string columns in 1 table)
> Any hints on how to do this?
> Thanks
>
>

Thursday, March 8, 2012

backupset

Here is my situation:
I have a stored procedure that runs full, differential and
log backups for a particular database.
Each backup has unique name based on the type, day of the
week and the time (e.g. Full_Backup_Monday_12-30).
Thus, backups are kept for one week.
When I review the backup set table, I see the name of my
backup, but in many cases I see an old date for the backup
and start and completion dates. However, when I review
the server, the newer backups are present.
My questions are:
Why isn't the backupset table being updated with the most
recent information?
When is the backupset table updated?
Thanks,
MichaelHi Michael,
Could you create a database backup as following steps?
1. Expand a server group, and then expand a server.
2. Expand databases, right-click the database, point to all tasks, and then
click backup database
3. Type the backup set name in the Name box and Select Database -complete
4. Under Destination, click Tape or Disk, and then specify a backup
destination.
If no backup destinations appear, click Add to add an existing backup
device or to create a new one.
5. Click Ok to create (Don't select the Schedule check box)
6. Check to see the backupset table again.
Is the backupset table updated immediately?
According to my test, the backupset table is updated on my side. When a
real backup finishes, a new record will be inserted in the table. Does it
work on your side? Generally, we do not recommended to directly query
system table. Could you tell me your detailed scenario?
This posting is provided "AS IS" with no warranties, and confers no rights.
Sincerely,
Michael Shao
Microsoft Support Engineer
| Content-Class: urn:content-classes:message
| From: "Michael" <michael_schall@.unionsanitary.com>
| Sender: "Michael" <michael_schall@.unionsanitary.com>
| Subject: backupset
| Date: Mon, 7 Jul 2003 16:51:46 -0700
| Lines: 22
| Message-ID: <06c801c344e2$b9f90bf0$a301280a@.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNE4rn5YC8MduACSZi2OM0YFuqZFQ==| Newsgroups: microsoft.public.sqlserver.server
| Path: cpmsftngxa09.phx.gbl
| Xref: cpmsftngxa09.phx.gbl microsoft.public.sqlserver.server:23185
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.sqlserver.server
|
| Here is my situation:
|
| I have a stored procedure that runs full, differential and
| log backups for a particular database.
|
| Each backup has unique name based on the type, day of the
| week and the time (e.g. Full_Backup_Monday_12-30).
| Thus, backups are kept for one week.
|
| When I review the backup set table, I see the name of my
| backup, but in many cases I see an old date for the backup
| and start and completion dates. However, when I review
| the server, the newer backups are present.
|
| My questions are:
| Why isn't the backupset table being updated with the most
| recent information?
|
| When is the backupset table updated?
|
| Thanks,
| Michael
|