Thanks, George! I do need a variable, since I need to send it off on its merry way in the world (i.e. to email) afterwards, but I didn't think of building it all in one big select/case statement. Thank you! :)
My ex-boyfriend had debt collectors who called our number, and when he moved out (and I kept the same phone number) I occasionally got calls for him. I basically said "he doesn't live here anymore, but I know he works, or used to work anyway, XYZ company. Here's their phone number, perhaps...
Have a look at http://forge.mysql.com/snippets/view.php?id=4 -- it's for mysql but you could probably use the same logic to make code that works for you.
Here's the actual code, if it helps... This has been changed to run interactively in Query Analyzer, rather than running as a stored procedure and sending email at the end, rather than a select *... but you should get the idea!
declare @newPID int, @oldPID int
, @Val varchar(30), @oVal...
Query Analyzer, perhaps? If so, get your SQL Server install disks, act like you're trying to install server, and at some point in the installation it will say "oh hey, you can't install server on a workstation! do you want to install the client tools only?" and then say yes. :)
If the entries are already null, then they're not unique. You can create the index with NO CHECK (remove the checkmark from "Check existing data on creation") which means "from this point on, make sure it's unique" but it's probably better if you fill in the data first. You should also...
I haven't tested this but could you change
CASE WHEN COUNT(P.State) > 1 THEN 'Various' END
to something like:
CASE WHEN MIN(P.State) <> MAX(P.State) THEN 'Various' ELSE MIN(P.State) END
I have a table called Position that has a structure similar to the following:
PositionID - unique key
PersonnelID - foreign key
Company
Start Date
End Date
Address1
City
etc etc etc
When a new row is inserted, I want to compare it to the previous row for the same personnel ID, and then send an...
If this is something you have to do frequently, you might want to investigate Red Gate's SQL bundle. They have various compare tools, one of which compares the data in two SQL databases. I don't know if that would help you with this particular problem, since your files are MDB and CSV, but...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.