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
 SQL Server Development (2000)
 SQL Query- Can I?

Author  Topic 

dupati1
Posting Yak Master

123 Posts

Posted - 2004-03-30 : 15:40:26
Hello Everyone,

Can i write a query something like this...

strSQL = "UPDATE Table1,Table2 SET Name='"&request("name")&"',Date_Bought='"&request("pdate")&"',Table1.ActiveInd='0',Table2.ActiveInd='0' WHERE Table1.InventID=Table2.CompID "

but the above query is not working?? How should i work around on this situation?

Thanks

VJ

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-30 : 15:41:15
What's wrong with the query? Could you post the query so that we can copy it into Query Analyzer? You are posting application code, we need T-SQL code.

Tara
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-03-30 : 18:36:15
If you're running this against SQL Server, your syntax is completely wrong. You need to create a procedure to do the update and call that procedure from your application. EXEC query 'col1','col2' etc.

If you aren't going to use procedures, which you really should, you need to change it to two updates. The syntax for UPDATE in SQL Server is

UPDATE t1
SET
t1.col2 = @value1,
t1.col3 = @value2
FROM
table1 t1
INNER JOIN table1 t2 ON t1.col1 = t2.col2



MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -