Using token ? in the format "" will rescue in case the database names in the Microsoft SQL Server instance have space characters.īut the same point is just the opposite for the undocumented sp_MSForEachTable proc syntax. 3 Answers Sorted by: 31 You can use spexecutesql with an output parameter to retrieve the scalar result. If you want to select the database name or the table name as a literal in the t-sql expression you should use double single quotes around the ? literal.Īlso the sp_MSForEachDB syntax enables the SQL Server developers or administrators to use instead of ?. The literal ? is used as a token which is replace with database name or table name according to the executed stored procedure " sp_MSForEachDB" or " sp_MSForEachTable". SQL Server tutorial shows how to use sp_MSForEachDB and sp_MSForEachTable undocumented stored procedures for database programmers and SQL Server administrators to ease their daily tasks. Turn on cmd shell may need a sysadmin account EXEC 'show advanced options', 1 RECONFIGURE WITH OVERRIDE EXEC 'xpcmdshell', 1 RECONFIGURE WITH OVERRIDE Declare sqlFilePath nvarchar (255)''C:\BPA Exports\Change Point 1\Processing\'' Declare sqlfilename nvarchar (255)'ExportCP1Data' Declare. The call and error handling is identical for each one except for the name of the procedure. It is a master procedure that essentially call multiple other subprocedures in sequence. SQL Server Undocumented Stored Procedures sp_MSForEachDB and sp_MSForEachTable in Example T-SQL Codes 6 I have a stored procedure written in T-SQL (SQL Server 2008 R2).
0 Comments
Leave a Reply. |