-- =============================================
-- Create date: 2010.11.01
-- Description: Gets the AX table ID for the table name
-- =============================================
ALTER FUNCTION [dbo].[fnAXTableID]
(
-- Add the parameters for the function here
@tableName nvarchar(40)
)
RETURNS int
AS
BEGIN
-- Declare the return variable here
DECLARE @tableNum int
-- Add the T-SQL statements to compute the return value here
SELECT @tableNum = TableID
FROM SQLDictionary
WHERE [Name] = @tableName
AND FieldID = 0
AND Array = 0
-- Return the result of the function
RETURN @tableNum
END
Tips and Tricks for Microsoft Dynamics AX, now Microsoft Dynamics 365 for Finance and Operations, also formerly known as Dynamics AX 4.0, 2009, 2012 and even Axapta.
Monday, January 10, 2011
Determine table ID in SQL
Create this function to easily get the table number within a SQL statement.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment