Solved

execute alter on another database

Posted on 2013-11-09
4
163 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 500 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

726 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