We have a mixture of 32-bit and 64-bit database servers, all running SS2K5 SP2.
In various scripts and procedures (particulary when executing an SSIS package using DTExec), I need to know which platform I am running from (ie 32-bit or 64-bit).
I am trying to create a function that will simply tell me whether it is 64-bit or 32-bit. Here is the code:
CREATE FUNCTION dbo.fnS_Is_64bit_SQL ()
DECLARE @Is64bit bit
DECLARE @MSVer table(
[Index] int not null,
[Name] varchar(255) not null,
Internal_Value int null,
Character_Value varchar(1024) null
INSERT INTO @MSVer ([Index], [Name], Internal_Value, Character_Value)
EXEC xp_msver 'FileDescription'
SELECT @Is64bit = CASE WHEN charindex('64', Character_Value, 1) > 0 THEN 1 ELSE 0 END
It generates an error message when trying to create the function:
"Invalid use of side-effecting or time-dependent operator in 'INSERT EXEC' within a function."
According to BOL, the following are all valid within UDFs
"UPDATE, INSERT, and DELETE statements modifying table variables that are local to the function."
"EXECUTE statements calling an extended stored procedure."
Why am I unable to create this function?
Any assistance gratefully received!