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
 General SQL Server Forums
 New to SQL Server Programming
 update

Author  Topic 

sprasad
Starting Member

2 Posts

Posted - 2008-11-03 : 19:17:58
Update EnvCVTPhase2.dbo.cse
Set EnvCVTPhase2.dbo.cse.usr_db_id = Ref_Master.dbo.Usr_Align.Usr_db_Id
SELECT EnvCVTPhase2.dbo.Cse.case_id, EnvCVTPhase2.dbo.Cse.physician_id,
EnvCVTPhase2.dbo.Physician.state_id,
Ref_Master.dbo.Usr_Align.Usr_db_Id
FROM EnvCVTPhase2.dbo.Cse ,
-- EnvCVTPhase2.dbo.Physician ,
Ref_Master.dbo.Usr_Align
ON EnvCVTPhase2.dbo.Cse.physician_id = EnvCVTPhase2.dbo.Physician.physician_id
AND EnvCVTPhase2.dbo.Cse.state_id = Ref_Master.dbo.Usr_Align.Align_Value
AND EnvCVTPhase2.dbo.Physician.state_id = Ref_Master.dbo.Usr_Align.Align_Value
--order by Ref_Master.dbo.Usr_Align.Usr_db_Id


I get the following error message
Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'ON'.

What would the fix

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-03 : 19:25:19
I tried my best but what you posted doesn't make much sense without an explanation. Here's my try:

UPDATE c
SET usr_db_id = ua.Usr_db_Id
FROM EnvCVTPhase2.dbo.Cse c
INNER JOIN EnvCVTPhase2.dbo.Physician p
ON c.physician_id = p.physician_id
INNER JOIN Ref_Master.dbo.Usr_Align ua
ON c.state_id = ua.Align_Value AND p.state_id = ua.Align_Value

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-03 : 23:48:41
or is it this?
Update c  
Set c.usr_db_id = ua.Usr_db_Id
FROM EnvCVTPhase2.dbo.Cse c
JOIN EnvCVTPhase2.dbo.Physician p
ON c.physician_id = p.physician_id
JOIN Ref_Master.dbo.Usr_Align ua
ON c.state_id = ua.Align_Value
AND p.state_id = ua.Align_Value

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-04 : 13:57:10
How is that different from mine?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2008-11-04 : 14:59:40
quote:
Originally posted by sprasad

Update EnvCVTPhase2.dbo.cse
Set EnvCVTPhase2.dbo.cse.usr_db_id = Ref_Master.dbo.Usr_Align.Usr_db_Id
SELECT EnvCVTPhase2.dbo.Cse.case_id, EnvCVTPhase2.dbo.Cse.physician_id,
EnvCVTPhase2.dbo.Physician.state_id,
Ref_Master.dbo.Usr_Align.Usr_db_Id
FROM EnvCVTPhase2.dbo.Cse ,
-- EnvCVTPhase2.dbo.Physician ,
Ref_Master.dbo.Usr_Align
ON EnvCVTPhase2.dbo.Cse.physician_id = EnvCVTPhase2.dbo.Physician.physician_id
AND EnvCVTPhase2.dbo.Cse.state_id = Ref_Master.dbo.Usr_Align.Align_Value
AND EnvCVTPhase2.dbo.Physician.state_id = Ref_Master.dbo.Usr_Align.Align_Value
--order by Ref_Master.dbo.Usr_Align.Usr_db_Id


I get the following error message
Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'ON'.

What would the fix




sprasad, you mixed syntax styles. You either need your syntax to use FROM ... JOIN ... ON ... or it would use FROM ... , ... WHERE ... = ...

You blended the ON without the JOIN and wihtout a WHERE.

Tara's rewrite should work fine for you.

---------------------------
EmeraldCityDomains.com
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-11-04 : 15:31:05
quote:
Originally posted by tkizer

How is that different from mine?

Tara Kizer




Well, it did increase HIS posting count. I think I finally figured out his secret!! - JK (and by stating this bit of info, I increased mine as well - WooHoo!)

Terry
Go to Top of Page

sprasad
Starting Member

2 Posts

Posted - 2008-11-05 : 14:22:40
Tara, Appreciate your feebback --- did implementation on the code and in process of testing ...
Thanks a bunch!!!!!!!!!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-05 : 16:14:08
You're welcome. Let us know if you need further assistance.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-11-05 : 16:29:18
quote:
Originally posted by tosscrosby

quote:
Originally posted by tkizer

How is that different from mine?

Tara Kizer




Well, it did increase HIS posting count. I think I finally figured out his secret!! - JK (and by stating this bit of info, I increased mine as well - WooHoo!)

Terry


What is the meaning of JK?
Is it "just kidding"?

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-11-05 : 16:54:40
[/quote]
What is the meaning of JK?
Is it "just kidding"?

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
[/quote]

It is. I didn't want to offend visakh. I know he's a posting madman and 99.999999% are good/great examples of code. Just wanted to give him the business since he did post the same code as Tara.

Terry
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-11-05 : 17:08:18
It is what I thought.
But visa is not a posting madman - he (it) is a new kind of posting bot!

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Kobojunkie
Starting Member

8 Posts

Posted - 2008-11-05 : 17:35:54
Update
EnvCVTPhase2.dbo.cse
Set
EnvCVTPhase2.dbo.cse.usr_db_id =Ref_Master.dbo.Usr_Align.Usr_db_Id

from(
SELECT
EnvCVTPhase2.dbo.Cse.case_id,
EnvCVTPhase2.dbo.Cse.physician_id,
EnvCVTPhase2.dbo.Physician.state_id,
Ref_Master.dbo.Usr_Align.Usr_db_Id
FROM
EnvCVTPhase2.dbo.Cse
inner join EnvCVTPhase2.dbo.Physician
ON EnvCVTPhase2.dbo.Cse.physician_id = EnvCVTPhase2.dbo.Physician.physician_id
inner join Ref_Master.dbo.Usr_Align
On EnvCVTPhase2.dbo.Cse.state_id = Ref_Master.dbo.Usr_Align.Align_Value
AND EnvCVTPhase2.dbo.Physician.state_id = Ref_Master.dbo.Usr_Align.Align_Value
--order by Ref_Master.dbo.Usr_Align.Usr_db_Id
)
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-11-06 : 08:11:38
quote:
Originally posted by webfred

he (it) is a new kind of posting bot!

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.



Agreed. Over 2K posts in what, the last 4 weeks?? He must eat, sleep and breath postings!

Terry
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-06 : 09:07:48
quote:
Originally posted by tosscrosby



What is the meaning of JK?
Is it "just kidding"?

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
[/quote]

It is. I didn't want to offend visakh. I know he's a posting madman and 99.999999% are good/great examples of code. Just wanted to give him the business since he did post the same code as Tara.

Terry
[/quote]
Sorry that was not intentional. It seems like I didnt read Taras post clearly. Apologies. I think i need to read previous suggestions twice before posting from now on
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-06 : 09:22:26
quote:
Originally posted by tosscrosby

quote:
Originally posted by webfred

he (it) is a new kind of posting bot!

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.



Agreed. Over 2K posts in what, the last 4 weeks?? He must eat, sleep and breath postings!

Terry


Not exactly. But still takes serious amount of time
Go to Top of Page

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2008-11-06 : 09:26:48
[/quote]
Sorry that was not intentional. It seems like I didnt read Taras post clearly. Apologies. I think i need to read previous suggestions twice before posting from now on
[/quote]

If anything, apologies should be mine. I was simply trying to inject a little humor and give you a hard time (I've seen 2 congrats on posting milestones for you in the past month so maybe a little jealousy on my part?? - naw, not my style). As webfred put it - "he (it) is a new kind of posting bot" - and I find it simply amazing. Keep up the good work.

Terry
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-06 : 09:31:00
quote:
Originally posted by tosscrosby



Sorry that was not intentional. It seems like I didnt read Taras post clearly. Apologies. I think i need to read previous suggestions twice before posting from now on
[/quote]

If anything, apologies should be mine. I was simply trying to inject a little humor and give you a hard time (I've seen 2 congrats on posting milestones for you in the past month so maybe a little jealousy on my part?? - naw, not my style). As webfred put it - "he (it) is a new kind of posting bot" - and I find it simply amazing. Keep up the good work.

Terry
[/quote]
No problem Terry
I felt bad as i myself hate duplicate suggestions. No worries.
Go to Top of Page
   

- Advertisement -