Click here to Skip to main content
15,911,531 members
Home / Discussions / Database
   

Database

 
GeneralRe: Beginner OLE question Pin
ThomasH13-Oct-04 12:58
ThomasH13-Oct-04 12:58 
GeneralRe: Beginner OLE question Pin
errenden4-Oct-04 5:23
errenden4-Oct-04 5:23 
GeneralRe: Beginner OLE question Pin
ThomasH14-Oct-04 13:04
ThomasH14-Oct-04 13:04 
GeneralRe: Beginner OLE question Pin
errenden5-Oct-04 3:59
errenden5-Oct-04 3:59 
GeneralTransaction SQL help (SQL Server 2000) Pin
Matt Newman30-Sep-04 6:31
Matt Newman30-Sep-04 6:31 
GeneralRe: Transaction SQL help (SQL Server 2000) Pin
Colin Angus Mackay30-Sep-04 7:19
Colin Angus Mackay30-Sep-04 7:19 
GeneralRe: Transaction SQL help (SQL Server 2000) Pin
Matt Newman30-Sep-04 7:27
Matt Newman30-Sep-04 7:27 
GeneralRe: Transaction SQL help (SQL Server 2000) Pin
Colin Angus Mackay30-Sep-04 9:51
Colin Angus Mackay30-Sep-04 9:51 
If it is a single command then you don't need to transact it. SQL Server will do that for you (hence Transacted-SQL).

If you have a stored procedure with more than one command then you can check each command has succeeded e.g.

UPDATE authors SET au_id = '172 32 1176'
WHERE au_id = "172-32-1176"
IF @@ERROR = 547
   print "A check constraint violation occurred"


Remember that the @@ERROR is only for the last command, so if you want to check its value a number of times in order to, say, perform different actions depending on what the error is you need to store it in the following statement.

DECLARE @errorCode int
UPDATE authors SET au_id = '172 32 1176'
WHERE au_id = "172-32-1176"
SELECT @errorCode = @@ERROR
IF @errorCode = 0
    COMMIT TRANSACTION
IF @errorCode = 547
    ROLLBACK TRANSACTION


Does this help?


Do you want to know more?

Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!


GeneralRe: Transaction SQL help (SQL Server 2000) Pin
Matt Newman30-Sep-04 10:31
Matt Newman30-Sep-04 10:31 
GeneralADO memory leak Pin
Droiddr29-Sep-04 23:47
Droiddr29-Sep-04 23:47 
GeneralRe: ADO memory leak Pin
sreejith ss nair7-Oct-04 0:53
sreejith ss nair7-Oct-04 0:53 
GeneralRunning SQL Agent from VB.NET and getting execution status Pin
Emilio Crespo29-Sep-04 6:53
Emilio Crespo29-Sep-04 6:53 
Generalvery strange behaviour Pin
ricardojb29-Sep-04 5:54
ricardojb29-Sep-04 5:54 
GeneralRe: very strange behaviour Pin
sreejith ss nair7-Oct-04 0:51
sreejith ss nair7-Oct-04 0:51 
GeneralStored Procedures and Return Values Pin
Ryan@SalamanderTechnologies29-Sep-04 3:53
sussRyan@SalamanderTechnologies29-Sep-04 3:53 
GeneralRe: Stored Procedures and Return Values Pin
Colin Angus Mackay29-Sep-04 4:41
Colin Angus Mackay29-Sep-04 4:41 
GeneralStored procedure / query optimization Pin
Vagif Abilov28-Sep-04 7:47
professionalVagif Abilov28-Sep-04 7:47 
GeneralRe: Stored procedure / query optimization Pin
Steven Campbell28-Sep-04 8:19
Steven Campbell28-Sep-04 8:19 
GeneralRe: Stored procedure / query optimization Pin
Vagif Abilov28-Sep-04 8:52
professionalVagif Abilov28-Sep-04 8:52 
GeneralRe: Stored procedure / query optimization Pin
Steven Campbell28-Sep-04 9:48
Steven Campbell28-Sep-04 9:48 
GeneralRe: Stored procedure / query optimization Pin
Vagif Abilov28-Sep-04 9:55
professionalVagif Abilov28-Sep-04 9:55 
GeneralRe: Stored procedure / query optimization Pin
Colin Angus Mackay28-Sep-04 23:12
Colin Angus Mackay28-Sep-04 23:12 
GeneralRe: Stored procedure / query optimization Pin
Bill Dean29-Sep-04 6:31
Bill Dean29-Sep-04 6:31 
GeneralRe: Stored procedure / query optimization Pin
Steven Campbell29-Sep-04 8:30
Steven Campbell29-Sep-04 8:30 
GeneralRe: Stored procedure / query optimization Pin
Colin Angus Mackay29-Sep-04 13:24
Colin Angus Mackay29-Sep-04 13:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.