Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Wednesday, March 21, 2012

Is it possible to convert T-SQL 2005 to T-SQL 2000

I am working with the Web Service Software Factory and I have created my stored procedures that I will be needing. The problem is that when I try to apply the SP's to the database, I receive errors regarding the syntax. I am using SQL Server 2000 and it generates the script in 2005 T-SQL format. The script in 2005 is quite different from 2000 and I am not sure if converting it is even possible (eg. no try catch equivalent in 2000 and new error handling ). I searched msdn to check if I could specify the script version in WSSF, but I could not find anything. Any suggestions as to how I might solve this without purchasing SQL Server 2005?

The Web Service Software Factory had created this sql file that included the following function that is used throughout the file:

Code Snippet

IF NOT EXISTS (SELECT NAME FROM dbo.sysobjects WHERE TYPE = 'P' AND NAME = 'RethrowError')

BEGIN

EXEC('CREATE PROCEDURE [dbo].RethrowError AS RETURN')

END

GO

ALTER PROCEDURE RethrowError AS

/* Return if there is no error information to retrieve. */

IF ERROR_NUMBER() IS NULL

RETURN;

DECLARE

@.ErrorMessage NVARCHAR(4000),

@.ErrorNumber INT,

@.ErrorSeverity INT,

@.ErrorState INT,

@.ErrorLine INT,

@.ErrorProcedure NVARCHAR(200);

/* Assign variables to error-handling functions that

capture information for RAISERROR. */

SELECT

@.ErrorNumber = ERROR_NUMBER(),

@.ErrorSeverity = ERROR_SEVERITY(),

@.ErrorState = ERROR_STATE(),

@.ErrorLine = ERROR_LINE(),

@.ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-');

/* Building the message string that will contain original

error information. */

SELECT @.ErrorMessage =

N'Error %d, Level %d, State %d, Procedure %s, Line %d, ' +

'Message: '+ ERROR_MESSAGE();

/* Raise an error: msg_str parameter of RAISERROR will contain

the original error information. */

RAISERROR(@.ErrorMessage, @.ErrorSeverity, 1,

@.ErrorNumber, /* parameter: original error number. */

@.ErrorSeverity, /* parameter: original error severity. */

@.ErrorState, /* parameter: original error state. */

@.ErrorProcedure, /* parameter: original error procedure name. */

@.ErrorLine /* parameter: original error line number. */

);

GO

And the error I receive is this ( I added 'machine\instance' to make it more generic):

Code Snippet

Msg 195, Level 15, State 10, Server Machine\Instance, Procedure RethrowError, Line 4
'ERROR_NUMBER' is not a recognized function name.
Msg 195, Level 15, State 10, Server Machine\Instance, Procedure RethrowError, Line 19
'ERROR_NUMBER' is not a recognized function name.
Msg 195, Level 15, State 10, Server Machine\Instance, Procedure RethrowError, Line 30
'ERROR_MESSAGE' is not a recognized function name.
Msg 170, Level 15, State 1, Server Machine\Instance, Procedure InsertUsers, Line 29
Line 29: Incorrect syntax near 'TRY'.
Msg 170, Level 15, State 1, Server Machine\Instance, Procedure InsertUsers, Line 37
Line 37: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Server Machine\Instance, Procedure InsertUsers, Line 41
Incorrect syntax near the keyword 'END'.
Msg 156, Level 15, State 1, Server Machine\Instance, Procedure InsertUsers, Line 44
Incorrect syntax near the keyword 'END'.
Msg 170, Level 15, State 1, Server Machine\Instance, Procedure UpdateUsers, Line 31
Line 31: Incorrect syntax near 'TRY'.
Msg 170, Level 15, State 1, Server Machine\Instance, Procedure UpdateUsers, Line 40
Line 40: Incorrect syntax near 'TRY'.
Msg 156, Level 15, State 1, Server Machine\Instance, Procedure UpdateUsers, Line 44
Incorrect syntax near the keyword 'END'.
Msg 156, Level 15, State 1, Server Machine\Instance, Procedure UpdateUsers, Line 47
Incorrect syntax near the keyword 'END'.

The other errors involving the try-catch and end revolve around the try-catch syntax where it does not recognize the rethrowerror function.

Code Snippet

BEGIN TRY

Do Something

END TRY

BEGIN CATCH

EXEC RethrowError;

END CATCH

Any suggestions as to how I could convert this without having to rewrite the sql file generated the project tools? Thanks in advance.

You will have to remove the exception handling code (it is new in SQL Server 2005). You need to also remove references to the ERROR* functions. Only @.@.ERROR was available before.|||That seems so easy. I cant believe I didnt think of that on my own! Thanks for your help.

Wednesday, March 7, 2012

Is is it advisable for SQL installation folder to be on the same drive as Windows?

Hey Community,

What are the guidelines for installing the SQL Software? Is it bottleneck if both Windows and SQL software are installed on the same drive ( I have all the database .mdfs and and .ldfs on a seperate RAID array)?

thanks,
Saptagiri Tangudu
PNT Marketing Services

Under normal situations, that is not a problem, and is often done that way.

Friday, February 24, 2012

is DB publication/subscription?

Because of problems trying to alter databases used
for replication my software would need to find out
if a database is a publisher or was repliated (using
T-SQL). Is this possible?Look in BOL for sp_dboption

This should be able to tell you if the database is Published etc

Cheers