Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Noob trying to pass a variable into T-SQL 1

Status
Not open for further replies.

OrthoDocSoft

Programmer
May 7, 2004
291
US
Folks,

I'm just cutting my teeth on stored proceedures and I think you can pass values into them from VB6 code, am I right?

This is what I have as a stored procedure:

Code:
CREATE Procedure dbo.UpdateORResultsGrid
(@strORName nvarchar(50))
As 
SET NOCOUNT ON
Update frozens
Set    ORStatus = 'ORResultQueued'
From   pathdesk       
		Inner Join frozens
On  pathdesk.UniqueNumber = frozens.UniqueNumber
		And pathdesk.Room = frozens.Room
Where (frozens.Room) = @strORName
And (frozens.ORStatus <> 'SurgeryOver'        
And (pathdesk.PathStatus) = 'Final'

Select                     (1st problem here)
frozens.FirstName,
frozens.MI,
frozens.LastName,
frozens.AccountNumber,
frozens.History,
frozens.Specimen,
frozens.SpecimenType,
frozens.Description,
frozens.SpecimenID,
frozens.ORStatus,
frozens.Surgeon,
pathdesk.Gross,
pathdesk.FrozenDx,
pathdesk.DxType,
pathdesk.PathStatus,
pathdesk.Pathologist,
pathdesk.RoomWhereSignedOut,
pathdesk.PhoneWhereSignedOut,
pathdesk.IntercomWhereSignedOut

From   frozens       
		Inner Join pathdesk         
On  frozens.UniqueNumber = pathdesk.UniqueNumber         
	And frozens.Room = pathdesk.Room
Where (frozens.Room) = @strORName
And (frozens.ORStatus <> 'SurgeryOver'        
And (pathdesk.PathStatus) = 'Final' (second problem here)

Problem is that I get the "underlines" on my "Select" statement (first problem line highlighted above) and when I mouseover, it says "expecting ")", AND, OR"

AND

I get an "incorect syntax error after 'Final' (second problem highlighted). And of course MSSQL Server won't execute the CREATE or ALTER.

Can anyone see the problem?

Thanks,
Ortho

[lookaround] "you cain't fix 'stupid'...
 
The real problem is here:

Code:
Where [!]([/!]frozens.Room[green][b])[/b][/green] = @strORName
And [!]([/!]frozens.ORStatus <> 'SurgeryOver'        
And [!]([/!]pathdesk.PathStatus[green][b])[/b][/green] = 'Final'

Hint: Every open prenthesis must have a close parenthesis.

Truth is, you don't actually need any of them in this case. In fact, the only time I use parenthesis in a where clause is whan I mix AND with OR.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
You know,

I TRY to see things like that before I post them, but alas....

George, you are the bomb.

Thank you so much,

Mark

[lookaround] "you cain't fix 'stupid'...
 
I saw them too right away. Don't put () when you don't need them and you would not find yourself in this predicatment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top