update SQL help again

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

hi again,

i did get a reply (THANKS!), but it still shows that i
have a syntax error - missing operator. could someone
please proofread the following SQL statement for me again?

thanks again,
Rob

UPDATE [Case Info] SET LAWYER = tbl-LAWYERMembership.FULL
WHERE
tbl-LAWYERMembership.ResponseCheckBox = 'TRUE'
from tbl-LAWYERMembership;
 
You can test your own SQL statements using the Query Analyzer. Copy,
paste, run and read the error messages in the results pane. Based on
the error messages, look up the syntax in SQL Books Online. There's
always sample T-SQL at the end of every reference item. If you don't
have QA, purchase the Developer edition of SQL Server ($49). Note that
you can't use it as a production server, but it has the necessary
tools to create and secure SQL Server databases.

--Mary
 
Rob,

Mary's advice is excellent. No SQL Server developer should be without tools
like Query Analyzer, Profiler, DTS, and Enterprise Manager (not to mention
Books Online). Knowing that the purchasing process can take a while,
though, in the short term you might want to try a tool like msSQLed
(http://www.mssqled.com) which you can download immediately for Query
Analyzer-like functionality.

Also, to tide you over until you get the tools you need, I looked at what
you wrote and I think your problems are that (1) you need to quote some of
your object names (that is, surround them with square brackets or the
ANSI-standard double quotes, like you did with [Case Info]) and (2) you
reversed the order of the WHERE and FROM clauses. If I create some test
tables like so:

create table [tbl-LAWYERMembership] ([FULL] nvarchar(100), ResponseCheckBox
nvarchar(4))
create table [Case Info] (LAWYER nvarchar(40))

Then the following re-write of your UPDATE statement works:

UPDATE [Case Info] SET LAWYER = [tbl-LAWYERMembership].[FULL]
FROM [tbl-LAWYERMembership]
WHERE [tbl-LAWYERMembership].ResponseCheckBox = 'TRUE';

Best wishes,
Brian

P.S. You didn't ask, and this might out of your hands or it might be a
misunderstanding by me, but storing text values like 'TRUE' for
ResponseCheckBox might not be the best design. There is a
bit/boolean/true-false data type in SQL Server that might be more
appropriate; you can use that and compare to 1 or 0.
 
Back
Top