?
Solved

execute alter on another database

Posted on 2013-11-09
4
Medium Priority
?
167 Views
Last Modified: 2013-11-12
Dear all ,
Need to execute
 
alter [testTable]    drop column ColName ;  

Open in new window

which is belong to [Test2DB] while I am in context of [Master1DB].

I try to use :
 
alter [Test2DB].[testTable]    drop column ColName ;  

Open in new window

and
 
alter [Test2DB].[dbo].[testTable]    drop column ColName ;  

Open in new window


btw, I have  [testTable], ColName  in both database and all necessary permissions...
Also I don't want to use "USE" keyword.

thanks in advance.
0
Comment
Question by:ethar1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 41

Expert Comment

by:Sharath
ID: 39636589
This query should work.

alter [Test2DB].[dbo].[testTable]    drop column ColName ;  

Did you try?
0
 

Author Comment

by:ethar1
ID: 39636620
yes I try as written above and I got the error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Test2DB'.
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 2000 total points
ID: 39636645
Try

alter Table [Test2DB].[dbo].[testTable]    drop column ColName ;  

Open in new window


Drop column Syntax is
ALTER TABLE <TableName> DROP COLUMN <column>

Raj
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39636662
ALTER TABLE [Test2DB].[dbo].[testTable]  DROP COLUMN ColName ;
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question