Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
4,358

Enable sqlcmd mode in SQL Server Management Studio as described in following image.

Now in query editor type following SQL.

:SETVAR DatabaseName "SBOPRODIR"

:SETVAR SchemaName "dbo"

:SETVAR TableName "OITM"

USE $(DatabaseName);

SELECT * FROM $(SchemaName).$(TableName);

Note that I have set the value of the database, schema and table as a sqlcmd variable and I am executing the query using the same parameters.

SQLCMD is a relatively simple language to master and it also aids in doing various tasks easily.

References:

http://blogs.msdn.com/b/sql_server_appendix_z/archive/2013/02/23/sql-server-management-studio-sqlcmd...

http://blog.sqlauthority.com/2013/06/28/sql-server-how-to-set-variable-and-use-variable-in-sqlcmd-mo...

http://msdn.microsoft.com/en-us/library/ms188714.aspx

Regards,

Marcelo Silva Santos

Labels in this area