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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update via Select!

Author  Topic 

adila
Starting Member

5 Posts

Posted - 2006-02-04 : 10:49:56
Hello all,
How can I use UPDATE command inside the SELECT command (anywhere in WHERE clause, FROM clause or...).
I want to update sth. when i select sth.
Is it possible just with SELECT and nothing else?

stats
Starting Member

10 Posts

Posted - 2006-02-04 : 11:00:15
Why do u want to use it in a SELECT statement, u canj just use the update statement on its own:

UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value

the where clause is the same as u wud use in the select statement.

STaTs
Go to Top of Page

adila
Starting Member

5 Posts

Posted - 2006-02-04 : 11:07:50
It is needed for a SQL injection security test...

I need something like this:
select 1 where 1=1 or (update...)

Thanks
Go to Top of Page

stats
Starting Member

10 Posts

Posted - 2006-02-04 : 11:17:21
IF EXISTS (SELECT columnx FROM table_name WHERE columnx = valueP)
BEGIN
UPDATE table_name
SET columnx = new_value
WHERE columnx = valueP
END




STaTs
Go to Top of Page
   

- Advertisement -