I have a Data Transformation Task which is going to end up with 40-50 lines of code in it using table names which are quite lengthy. In order to make the code shorter and easier to read I am trying to substitute the table names with a variable but I am not having much joy and don't even know if this is possible.
As an example my code reads as follows: -
Declare @Trans nvarchar(80)
Set @Trans = '[R6_RELIAB_CURRENTDETAIL].[dbo].[TRANS_SERVINCIDENT]'
Select @Trans.[Transition_Field]
From @Trans
Rather than: -
Select [R6_RELIAB_CURRENTDETAIL].[dbo].[TRANS_SERVINCIDENT].[Transition_Field]
From [R6_RELIAB_CURRENTDETAIL].[dbo].[TRANS_SERVINCIDENT]
I have tried changing the variable type and length, dropping the ' marks and enclosing the @Trans in [].
Is what I am trying to do possible and if so how can I achieve it?
Many Thanks in advance.
As an example my code reads as follows: -
Declare @Trans nvarchar(80)
Set @Trans = '[R6_RELIAB_CURRENTDETAIL].[dbo].[TRANS_SERVINCIDENT]'
Select @Trans.[Transition_Field]
From @Trans
Rather than: -
Select [R6_RELIAB_CURRENTDETAIL].[dbo].[TRANS_SERVINCIDENT].[Transition_Field]
From [R6_RELIAB_CURRENTDETAIL].[dbo].[TRANS_SERVINCIDENT]
I have tried changing the variable type and length, dropping the ' marks and enclosing the @Trans in [].
Is what I am trying to do possible and if so how can I achieve it?
Many Thanks in advance.