Recently, SQL started learning and ran into the problem that I am unable to find the solution. I am trying to collect data from multiple databases and output it into a single table.
The source selects the output data in two columns "ACACT" and "Source DB"
The target table is "acAcct" and column for each database
The thing that I came up with is:
(1000) Set @command varchar announcement @command = 'if' '[?]' '(Not' '[guru]' ',' '[model]' '[msdb ] ',' '[Tempdb]' ') inserting into _utility.dbo.konta (acAcct,' '?' ') DISTINCT AC.acAcct,' '?' As AD.acName 'THE_AcctTransItem selects vDE_SetAccount as AC Left' AC.acAcct = AD.acAcct EXEC at SP_MSforeachdb @command
I get this error for each DB:
Wrong syntax near the message 102, level 15, state 1, line 3 'db name'
I think the variable parse I'm missing out with:
inserting in _utility.dbo.konta ('?' AcAcct, '') ([STT] @ command = 'IF' '[?] "No (" [Master] "," [Model] "," [MSDB] "," [Tempdb] ] '') Merge _Utility Dobo.Conta AS Use as Target (Active AC ACACCT, AD.KNM [[]] to [?] ADB Byte Join [d] as DBHHA ATTRIT [?]. DCA.A.C.T.C.T.DACACACACACACCTT = ADAACACCTT) (Source: ACACT = Source. ACACTT) when the SET target was fixed in it. [?] = Source. [?] When the INSERT (ACACT, [?]) Values were not found (source.acac, [?]); Original Kript is filled only the first column and misleading others.
"text"> If the name of the source database If there is a column, then it should not be added in single quotes. Square brackets will be safe.
@command varchar declaration (1000) set @command = 'if' '[?]' '(Not' '[guru]' ', [[model]], [' MSDB ], '' [Tempdi] '') _UTility.dbo.konta INSERT (ACACTT, [?]) Select AC ACACACct, AD.acName AS [?] To tHE_AcctTransItem as AC Left
Include vDE_SetAccount as AC.acAcct = AD.acAcct EXEC sp_MSforeachdb e @ @command
No comments:
Post a Comment