How to use a variable for object's owner (schema)? In Oracle we can use a variable instead of the object's owner. The value of this variable will be prompted by Oracle when the scripts starts.

Something like CREATE TABLE **&amp;owner.**MY_TABLE.

I'm trying to accomplish the same thing with SQL Server but I failed to find how to do it.
In modern versions of SQL Server, this is actually the schema, not the owner. You can't parameterize this and must concatenate a command:

DECLARE @schema sysname = N'owner';

DECLARE @sql nvarchar(max);
SET @sql = N'CREATE TABLE ' + QUOTENAME(@schema) + N'.my_table(cols...);';
EXEC sys.sp_executesql @sql;


If this is being specified by an end user, you may want to validate that it is a proper schema first, e.g.:

IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = @schema)
BEGIN
  RAISERROR(N'Invalid schema %s!', 11, 1, @schema);
  RETURN;
END


A really lazy way is to set the callers default schema to the target, and then don't specify the schema name. This is a bad idea but I'm mentioning it for completeness.