| Author |
Topic |
|
Hambonehock
Starting Member
5 Posts |
Posted - 2007-03-16 : 09:00:10
|
Good morning,I am trying to setup a bulk update function using a stored procedure that will take in a PK and use a Select Case to update a second table. The error I am getting on Excecute of Alter Procedure is: Msg 107, Level 16, State 3, Procedure sp_BulkUpload, Line 22The column prefix 'dbo.tblBulkUpdate' does not match with a table name or alias name used in the query. I am fairly certain I am making this more complicated than it needs to be but have not been able to find a solution. Any help is greatly appreciated.SProc:( @strRequestID varchar(100), @strActionAuthorizer varchar(50), @dtActionAuthDate datetime, @strActionAuthLocation varchar(16))AS SET NOCOUNT OFF;SELECT DISTINCT dbo.tblBulkUpdate.strRequestID, dbo.tblBulkUpdate.intFolderID, dbo.tblBulkUpdate.intFileID, CASE dbo.tblBulkUpdate.strPerformAction WHEN Upper('SAVE') THEN 0 WHEN Upper('DELETE') THEN 1 WHEN Upper('DELETED') THEN 2 END AS strPerformactionFROM dbo.tblBulkUpdate INNER JOIN dbo.tblScanResults ON dbo.tblBulkUpdate.strRequestID = dbo.tblScanResults.strRequestIDUPDATE dbo.tblScanResultsSET dbo.tblScanResults.strPerformAction = dbo.tblBulkUpdate.strPerformAction, strActionAuthorizer = @strActionAuthorizer, dtActionAuthDate = @dtActionAuthDate, strActionAuthLocation = @strActionAuthLocationWHERE (strRequestID = @strRequestID) AND (dbo.tblScanResults.intFolderID = dbo.tblBulkUpdate.intFolderID) AND (dbo.tblScanResults.intFileID = dbo.tblBulkUpdate.intFileID)Meg. Pffft. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 09:07:08
|
| [code]UPDATE srSET sr.strPerformAction = bu.strPerformAction, sr.strActionAuthorizer = bu.strActionAuthorizer, sr.dtActionAuthDate = bu.dtActionAuthDate, sr.strActionAuthLocation = bu.strActionAuthLocationFROM dbo.tblScanResults AS srINNER JOIN dbo.tblBulkUpdate AS bu ON bu.intFolderID = sr.intFolderID AND bu.intFileID = sr.intFileID AND bu.strRequestID = sr.strRequestID[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
Hambonehock
Starting Member
5 Posts |
Posted - 2007-03-16 : 09:18:35
|
| You really are a saint!One further piece of the puzzle is that I would like transform the text in bu to an int in srThe following returns error:Msg 156, Level 15, State 1, Procedure sp_BulkUpload, Line 16Incorrect syntax near the keyword 'AS'.UPDATE srSET sr.strPerformAction = CASE bu.strPerformAction WHEN Upper('SAVE') THEN 0 WHEN Upper('DELETE') THEN 1 WHEN Upper('DELETED') THEN 2 END AS Action, sr.strActionAuthorizer = bu.strActionAuthorizer, sr.dtActionAuthDate = bu.dtActionAuthDate, sr.strActionAuthLocation = bu.strActionAuthLocationFROM dbo.tblScanResults AS srINNER JOIN dbo.tblBulkUpdate AS bu ON bu.intFolderID = sr.intFolderID AND bu.intFileID = sr.intFileID AND bu.strRequestID = sr.strRequestIDThank you for the earlier speedy reply. This is the last piece of a puzzle before testing.Meg. Pffft. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 09:22:07
|
| [code]UPDATE srSET sr.strPerformAction = CASE UPPER(bu.strPerformAction) WHEN 'SAVE' THEN 0 WHEN 'DELETE' THEN 1 WHEN 'DELETED' THEN 2 END, sr.strActionAuthorizer = bu.strActionAuthorizer, sr.dtActionAuthDate = bu.dtActionAuthDate, sr.strActionAuthLocation = bu.strActionAuthLocationFROM dbo.tblScanResults AS srINNER JOIN dbo.tblBulkUpdate AS bu ON bu.intFolderID = sr.intFolderID AND bu.intFileID = sr.intFileID AND bu.strRequestID = sr.strRequestID[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 09:23:23
|
| Note that if bu.strPerformAction has any other value then 'SAVE', 'DELETE', 'DELETED'the sr.strPerformAction column will be NULL.Peter LarssonHelsingborg, Sweden |
 |
|
|
Hambonehock
Starting Member
5 Posts |
Posted - 2007-03-16 : 09:23:30
|
| Sorry. I went blindly unto that good night. Had to plug in my parameters as bu does not have the auth info:( @strRequestID varchar(100), @strActionAuthorizer varchar(50), @dtActionAuthDate datetime, @strActionAuthLocation varchar(16))AS SET NOCOUNT OFF;UPDATE srSET sr.strPerformAction = CASE bu.strPerformAction WHEN Upper('SAVE') THEN 0 WHEN Upper('DELETE') THEN 1 WHEN Upper('DELETED') THEN 2 END, sr.strActionAuthorizer = @strActionAuthorizer, sr.dtActionAuthDate = @dtActionAuthDate, sr.strActionAuthLocation = @strActionAuthLocationFROM dbo.tblScanResults AS srINNER JOIN dbo.tblBulkUpdate AS bu ON bu.intFolderID = sr.intFolderID AND bu.intFileID = sr.intFileID AND bu.strRequestID = sr.strRequestIDMeg. Pffft. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 09:29:01
|
| [code]( @strRequestID VARCHAR(100), @strActionAuthorizer VARCHAR(50), @dtActionAuthDate DATETIME, @strActionAuthLocation VARCHAR(16))ASSET NOCOUNT ONUPDATE srSET sr.strPerformAction = CASE UPPER(bu.strPerformAction) WHEN 'SAVE' THEN 0 WHEN 'DELETE' THEN 1 WHEN 'DELETED' THEN 2 -- ELSE -1 ??? Is this correct? Or should the value be NULL? END, sr.strActionAuthorizer = @strActionAuthorizer, sr.dtActionAuthDate = @dtActionAuthDate, sr.strActionAuthLocation = @strActionAuthLocationFROM dbo.tblScanResults AS srINNER JOIN dbo.tblBulkUpdate AS bu ON bu.intFolderID = sr.intFolderID AND bu.intFileID = sr.intFileID AND bu.strRequestID = sr.strRequestID[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
Hambonehock
Starting Member
5 Posts |
Posted - 2007-03-16 : 16:15:00
|
| I guess what I would like to do is skip that record. Is that possible?Meg. Pffft. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 17:17:57
|
| [code]UPDATE srSET sr.strPerformAction = CASE UPPER(bu.strPerformAction) WHEN 'SAVE' THEN 0 WHEN 'DELETE' THEN 1 WHEN 'DELETED' THEN 2 END, sr.strActionAuthorizer = @strActionAuthorizer, sr.dtActionAuthDate = @dtActionAuthDate, sr.strActionAuthLocation = @strActionAuthLocationFROM dbo.tblScanResults AS srINNER JOIN dbo.tblBulkUpdate AS bu ON bu.intFolderID = sr.intFolderID AND bu.intFileID = sr.intFileID AND bu.strRequestID = sr.strRequestIDWHERE UPPER(bu.strPerformAction) IN ('SAVE', 'DELETE', 'DELETED')[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
Hambonehock
Starting Member
5 Posts |
Posted - 2007-03-19 : 16:05:12
|
| Works like a charm. Thank you very much for your help.Meg. Pffft. |
 |
|
|
shijobaby
Starting Member
44 Posts |
Posted - 2009-08-20 : 03:05:38
|
| the column prefix does not match with a table name or alias name used in the query.I was also working to solve this errorNw i found why it is comming just needs to make small changes in queryhttp://sqlerrormessages.blogspot.com/2009/08/sql-server-error-messages-msg-107.html |
 |
|
|
|