Groups | Blog | Home
all groups > sql server new users > july 2005 >

sql server new users : SQL Statement Help


Hugo Kornelis
7/22/2005 12:00:00 AM
[quoted text, click to view]

Hi Jim,

Rich is correct - you can comma-seperate the assignments in the SET
clause. That will work in Access and SQL Server, as well as in every
other DBMS that supports at least basic level SQL-92 or higher (which is
probably every relational database).

UPDATE TClaimTrak
SET resolved = True
, notes = 'this is a note that goes in this field'
WHERE id = 40

(Note that I changed the double-quotes to single-quotes. Not sure how
Access handles this, but SQL Server needs single quotes as string
delimiters. Double quotes have a different function).

Best, Hugo
--

Jim in Arizona
7/22/2005 9:31:52 AM
I'm creating a vb.net web form that connects to an access database. I just
need clarification on a SQL statement.

Basically, I do a record update like so:

UPDATE TClaimTrak
SET resolved = True
WHERE id = 40

Now I need to not only do an update of a field, but also do update another
field at the same time .. so, something like this:

UPDATE TClaimTrak
SET resolved = True
SET notes = "this is a note that goes in this field"
WHERE id = 40

I don't think that would be the right way of doing it? IS there a right way
that can be done in a single statement. I know this is a SQL server group
and I'm working wtih access. I just figured that there would be some SQL
gurus in here that could help.

Since I'm using access, I can't, of course, do a stored proc.

TIA,
Jim

Rich
7/22/2005 10:02:03 AM
In article <uT4WcrtjFHA.476@TK2MSFTNGP14.phx.gbl>, Jim in Arizona says...
[quoted text, click to view]

I don't have much experience with Access but have a little with MySQL and
PostgreSQL and probably very similar. From my understanding you would group
multiple "sets" using a comma similar to selecting fields from multiple tables.
As an example I'd try....

UPDATE TClaimTrak
SET resolved = True, notes = "this is a note that goes in this field"
WHERE id = 40

Rich
--
Newsguy.Com - 30 GB - $14.95 / month
Complete posts and long retention times
http://newsguy.com/overview.htm
Jim in Arizona
7/22/2005 2:35:50 PM
[quoted text, click to view]

Thanks Rich! I didn't think there was a way.

I ended up doing a little extra coding to achieve the same result (before I
came back to this board but now that I know you can comma seperate 'em,
I'll be taking advantage of that in all future web forms!

Once again, thanks.

Jim

Jim in Arizona
7/22/2005 2:39:41 PM
[quoted text, click to view]

Hi Hugo.

Thanks for the reply. It's good to know that I can use the same thing for
both SQL and Access, if need be. I do use both for my website.
Also, yea, I realized that I should be using single quotes in my SQL
statements. I've been doing so much coding today that I just quickly threw
in double quotes without realizing it. Of course, that'll probably cause me
to debug some code later on too .. I can feel it comin'.

Thanks Again,
Jim

AddThis Social Bookmark Button