SQL 2012 :: Alter Database Set Partner Command Failed

Jun 23, 2014

Running this query in DR server to start SQL mirroring but encountered an error below.

Query:
use master
go
alter database test set partner= N'TCP://HOSTNAME.DOMAIN.GROUP.INTRANET:5023'
go

Error:
Msg 1452, Level 16, State 6, Line 2

The partner server instance name must be distinct from the server instance that manages the database. The ALTER DATABASE SET PARTNER command failed.

View 2 Replies


ADVERTISEMENT

ALTER DATABASE SET PARTNER OFF

Oct 25, 2006

I've read that when this run's, it removes all db mirroring information on that db. What exactly does it remove?

Here's my senario:

We are using SQL 2005€™s db mirroring process. We are using the certificate method of authentication between the principle and the mirror db€™s.

My question is that when the ALTER DATABASE dbname SET PARTNER OFF is run, does it remove these certificate settings as well? In other words when I want to enable the db mirroring, will I need to recreate these certificates or just recreate the endpoints to use these certificates?

View 5 Replies View Related

Database Mirroring Hangs On ALTER DATABASE SET PARTNER

Jun 26, 2005

Hi,

View 6 Replies View Related

Maitenace Plan Check Database Integrity Task Fails With Failed:(0) Alter Failed For Server 'xyz'

Feb 21, 2008



Hi,



I am administering several SQL Servers running SQL Server 2005 SP2 Build 3042.
I have a common maintenance plan that runs on each of the servers. The maintenance plan runs
fine on all the servers except for one. On the one server the Database Integrity check fails with the following error:


Check Database integrity on Local server connection
Databases: <list of databases>
Include indexes
Task start: 2008-02-21T00:05:42.
Task end: 2008-02-21T00:05:46.
Failed0) Alter failed for Server €˜XYZ€™

I created a test maintenance plan to just do the integrity check and selected one database only and this also failed with the same error message. I ran this test maintenance plan and configured it for each of the databases in question and it failed each time.
If I run the DBCC manually against the databases they all report fine.


I read some of the post that talked about the €œAllow Updates€? being set incorrectly but that does not apply to my problem since my configured and run values are set to 0.

Does anyone know what the problem could be?

View 23 Replies View Related

CANNOT SET PARTNER 'NT AUTHORITYANONYMOUS LOGON.' Failed

Dec 27, 2006

i tried to set up mirroring having only principal and mirror. mirroring endpoints were easily created for both servers. when i try to add the partner name it responds with
Msg 1418, Level 16, State 1, Line 1The server network address "TCP://machine1.domain.com:5022" can not be reached or does not exist. Check the network address name and that the ports for the local and remote endpoints are operational.
On the log of machine1 i see,
Database Mirroring login attempt by user 'NT AUTHORITYANONYMOUS LOGON.' failed with error: 'Connection handshake failed. The login 'NT AUTHORITYANONYMOUS LOGON' does not have CONNECT permission on the endpoint. State 84.'.

i have similar problems as in

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1020144&SiteID=1

i am a sysadmin on both SQL Servers and have connect permission on both end points.
Both the endpoints are in started state and listening to all IP's
Both services are as 'Local System'
As per what was mentioned in the above post to add a 'domain/machine$' user did not help.
Tried using setspn.exe to add a new SPN MSSQLsvc/<HOST>:<MIRRORINGPORT> did not work. an ERROR comes 'not enough privileges'
setup shows the following SPN only on both
HOST/Machine name
HOST/Machine name.Domin.com
MSSQLSvc/Machine name.Domin.com:1433
SMTPSVC/Machine name
SMTPSVC/machine name.Domain.com

and on second machine
HOST/Machine name

HOST/Machine name.Domin.com

MSSQLSvc/Machine name.Domin.com:1433

any Clues?

View 1 Replies View Related

Alter Database Failed

Mar 13, 2003

Hello,

I have Test database with Log file property Automatically grow the file, option Unrestricted file growth, I wanted to alter it with Restrict file growth upto 200 MB. I'm getting an error that you cannot modify as file doesnot exist
But the file does exist. I cannot figure out what is giving the problem.
below is the sql statements
select name from sysfiles
go

Test_Data
Test_Log

USE master
go
ALTER DATABASE Test MODIFY FILE
( NAME='Test_Log',
MAXSIZE=200MB )
go

ERROR
Server: Msg 5041, Level 16, State 1, Line 1
MODIFY FILE failed. File 'Test_Log' does not exist.

Any help is appreciated.

Thanks
Sejal

View 3 Replies View Related

SQL 2005 Won't Start After Moving Model Database With Alter DB Command

Sep 11, 2007

I used the code below to move the Model database and Model log file to new SAN drive locations.
After running the commands I stopped the SQL server and moved the physical files to the correct location.
Now I am unable to start SQL server, I get error 17204 Could not open file:Access is denied

I think the problem maybe that for FILENAME new_path I put "J:SQL ServerMSSQL.1MSSQLData"
but did not include model.mdf in the file path.

How do I correct the path now that SQL service won't start?
I have included the log file below.



ALTER DATABASE database_name MODIFY FILE ( NAME = logical_name , FILENAME = 'new_path/os_file_name' )


2007-09-11 13:19:31.82 Server Microsoft SQL Server 2005 - 9.00.3042.00 (X64)
Feb 10 2007 00:59:02
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
2007-09-11 13:19:31.82 Server (c) 2005 Microsoft Corporation.
2007-09-11 13:19:31.82 Server All rights reserved.
2007-09-11 13:19:31.82 Server Server process ID is 3264.
2007-09-11 13:19:31.82 Server Authentication mode is MIXED.
2007-09-11 13:19:31.82 Server Logging SQL Server messages in file 'D:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLLOGERRORLOG'.
2007-09-11 13:19:31.82 Server This instance of SQL Server last reported using a process ID of 2648 at 9/11/2007 1:10:02 PM (local) 9/11/2007 8:10:02 PM (UTC). This is an informational message only; no user action is required.
2007-09-11 13:19:31.82 Server Registry startup parameters:
2007-09-11 13:19:31.82 Server -d D:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAmaster.mdf
2007-09-11 13:19:31.82 Server -e D:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLLOGERRORLOG
2007-09-11 13:19:31.82 Server -l D:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAmastlog.ldf
2007-09-11 13:19:31.84 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2007-09-11 13:19:31.84 Server Detected 4 CPUs. This is an informational message; no user action is required.
2007-09-11 13:19:31.96 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2007-09-11 13:19:31.98 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2007-09-11 13:19:32.00 Server Attempting to recover in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2007-09-11 13:19:32.00 Server Database mirroring has been enabled on this instance of SQL Server.
2007-09-11 13:19:32.00 spid5s Starting up database 'master'.
2007-09-11 13:19:32.09 spid5s SQL Trace ID 1 was started by login "sa".
2007-09-11 13:19:32.10 spid5s Starting up database 'mssqlsystemresource'.
2007-09-11 13:19:32.10 spid5s The resource database build version is 9.00.3042. This is an informational message only. No user action is required.
2007-09-11 13:19:32.26 spid5s Server name is 'SS02'. This is an informational message only. No user action is required.
2007-09-11 13:19:32.26 spid9s Starting up database 'model'.
2007-09-11 13:19:32.26 spid9s Error: 17207, Severity: 16, State: 1.
2007-09-11 13:19:32.26 spid9s FCB:pen: Operating system error 5(Access is denied.) occurred while creating or opening file 'J:SQL ServerMSSQL.1MSSQLData'. Diagnose and correct the operating system error, and retry the operation.
2007-09-11 13:19:32.26 spid9s Error: 17204, Severity: 16, State: 1.
2007-09-11 13:19:32.26 spid9s FCB:pen failed: Could not open file J:SQL ServerMSSQL.1MSSQLData for file number 1. OS error: 5(Access is denied.).
2007-09-11 13:19:32.26 spid9s Error: 5120, Severity: 16, State: 101.
2007-09-11 13:19:32.26 spid9s Unable to open the physical file "J:SQL ServerMSSQL.1MSSQLData". Operating system error 5: "5(Access is denied.)".
2007-09-11 13:19:32.26 spid9s Error: 17207, Severity: 16, State: 1.
2007-09-11 13:19:32.26 spid9s FCB:pen: Operating system error 5(Access is denied.) occurred while creating or opening file 'I:SQL ServerMSSQL.1MSSQLData'. Diagnose and correct the operating system error, and retry the operation.
2007-09-11 13:19:32.26 spid9s Error: 17204, Severity: 16, State: 1.
2007-09-11 13:19:32.26 spid9s FCB:pen failed: Could not open file I:SQL ServerMSSQL.1MSSQLData for file number 2. OS error: 5(Access is denied.).
2007-09-11 13:19:32.26 spid9s Error: 5120, Severity: 16, State: 101.
2007-09-11 13:19:32.26 spid9s Unable to open the physical file "I:SQL ServerMSSQL.1MSSQLData". Operating system error 5: "5(Access is denied.)".
2007-09-11 13:19:32.26 spid9s File activation failure. The physical file name "I:SQL ServerMSSQL.1MSSQLData" may be incorrect.
2007-09-11 13:19:32.26 spid9s Error: 945, Severity: 14, State: 2.
2007-09-11 13:19:32.26 spid9s Database 'model' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
2007-09-11 13:19:32.26 spid9s Could not create tempdb. You may not have enough disk space available. Free additional disk space by deleting other files on the tempdb drive and then restart SQL Server. Check for additional errors in the event log that may indicate why the tempdb files could not be initialized.
2007-09-11 13:19:32.26 spid9s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

View 4 Replies View Related

SQL Security :: ALTER DATABASE Failed Because A Lock Could Not Be Placed On Database

Jul 20, 2015

I have a script that automates some db drop/restore operations and bringing the database to single user mode is part of it: ALTER DATABASE ... SET SINGLE_USER WITH ROLLBACK IMMEDIATE...I want this to executes under a login, that has restricted privileges, so I've created a login and granted it a dbcreator role + ALTER ANY DATABASE privileges.

Problem: When I run the script against a database with an active/sleeping connection:It fails when using the restricted login: "Msg 5061...ALTER DATA BASE failed because a lock could not be placed on database ..."It completes successfully when using a sysadmin login According to stackoverflow.com the solution is to kill the active/sleeping connections to the database, before ALTER-ing it, which works fine, but the question is....

Questions: Why the "ALTER DATABASE..." statement works under the sysadmin login, but not under a dbcreator one?Does this mean the sysadmin login kills the connections to the target database in the background?Is it possible to grant additional privileges to the restricted login, so the "ALTER DATABASE..." statement won't need preventive killing of the connections?

View 5 Replies View Related

SQL 2012 :: Create Linked Server With Failover Partner Option?

Jul 22, 2014

it is possible to create Linked server with Failover partner option. I can query when primary server and getting the error when I set the DB Fail over. I have tried with following script and also gone through different sources, but failed. Please see the script and error below.

EXEC master.dbo.sp_addlinkedserver
@server = N'MIRRORLink',
@srvproduct=N'',
@provider=N'SQLOLEDB',
@provstr=N'Server=primary;FailoverPartner=mirror;network=dbmssocn;',

[code].....

View 2 Replies View Related

URGENT: The Command Failed Because The Database Mirror Is Busy!

Mar 30, 2007

Hi,



Mirroring has been working fine on 2 identical servers. We even tested failover and that worked....but today something happened (still investigating) and suddenly the Principal is disconnected and we cannot force failover with:



ALTER DATABASE [LeoCTI] SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS



Error: The command failed because the database mirror is busy! Try again later!



How can I bring the principal back online? It won't let me do anything, won't let me turn off mirroring etc. etc.



HELP PLEASE!



Thanks

Hyper aka Richard

View 2 Replies View Related

SQL 2012 :: Error (backup Failed To Complete The Command BACKUP LOG) In Event Viewer

Aug 23, 2013

On the SQL Server the Event Viewer shows the same messages and errors every evening between 22:05:00 and 22:08:00. The following information messages are shown for every database:

"I/O is frozen on database <database name>. No user action is required. However, if I/O is not resumed promptly, you could cancel the backup."

"I/O was resumed on database <database name>. No user action is required."

"Database backed up. Database: <database name>, creation date(time): 2003/04/08(09:13:36), pages dumped: 306, first LSN: 44:148:37, last LSN: 44:165:1, number of dump devices: 1, device information: (FILE=1, TYPE=VIRTUAL_DEVICE: {'{A79410F7-4AC5-47CE-9E9B-F91660F1072B}4'}). This is an informational message only. No user action is required."

After the 3 messages the following error message is shown for every database:

"BACKUP failed to complete the command BACKUP LOG <database name>. Check the backup application log for detailed messages."

I have added a Maintenance Plan but these jobs run after 02:00:00 at night.

Where can I find the command or setup which will backup all databases and log files at 22:00:00 in the evening?

View 9 Replies View Related

Database Mirroring - Partner Requirements

Oct 25, 2007

Hello,

Am I reading it wrong or can I have a developer edition as a partner?

http://www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.mspx Please take a look at the Database Mirroring and SQL Server 2005 Editions section.

Anyone knows?

Thank you.

View 6 Replies View Related

SQL 2012 :: Restore Database Command - BufferCount Option?

Jul 22, 2014

What the BUFFERCOUNT option does in a RESTORE DATABASE command?

View 5 Replies View Related

Need Help With The ALTER Command

Dec 16, 2005

Hello everyone,
I just started learning sql and I came across a slight problem.
Assume I have a customer table composed of the following fields:
Customer_Number,Sname,Street,City,Postcode,credit_lim,balance.

What I want to do is to drop the Street,city,and postcode fields and add the following: fax,email,and phone.

Is it possible to use the following command:

Alter table customer
Drop column street,city,postcode

Or should I do as following:

Alter table customer
Drop column street

Alter table customer
Drop column city

Alter table customer
Drop column postcode

And the same goes to adding the phone,fax,and email field.
Thank You.

NB: I need to use the Alter command and nothing else

View 10 Replies View Related

ALTER Table Command

Jul 20, 2005

Hi,I'm trying to run the ALTER TABLE command using a dynamic string for thetable, like so:DECLARE @TableName CHARSET @TableName = 'Customers'ALTER TABLE @TableNameADD ...blahIs this possible? We know this works:ALTER TABLE Customers ADD ...blahIt looks like I need a way to convert the CHAR value to a literal or perhapseven a table ID?Thanks in advance,Paul

View 3 Replies View Related

Help Me Please I Have A Problem In ALTER Command

Sep 3, 2007



Dear all
I need to add new column in table TranPay , I use ALTER command on PDA on Button Click




Dim SqlStm = "ALTER TABLE TranPay ALTER COLUMN TranKey IDENTITY (1, 1)"

Dim Dcmd As SqlCeCommand = New SqlCeCommand

Dcmd.Connection = Conn

Dcmd.CommandText = SqlStm

Dcmd.ExecuteNonQuery()


But cannot create new Field , Help me please

Brg ,

Tingnong

View 3 Replies View Related

SQL 2012 :: Attach Database Failed

Jan 22, 2015

Is dere a way to attach backup file ? My current database have been corrupted but I do have backup of the that database and when if i try to attach that database its showing error. How can I restore database from backup file in this case?

View 8 Replies View Related

Adding The Column By Using The Alter Command.

Jun 1, 2008

ALTER TABLE customers
add column active_flg int(1)

but i got error.

quote:Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'column'.

what should i do?

ps. thanks for warning... i won't edit the post after i got the answer anymore.

View 6 Replies View Related

Add A Column Trough Command (ALTER)

Sep 12, 2013

I'm trying to add a column trough command "ALTER" and I've tried in many different ways.

Here is the result of statement..

View 1 Replies View Related

Extend Alter Procedure Command

Jun 27, 2007

Is there any way to extend the Alter Procedure command or fire somekind of event when it is executed in SQL Server 2005?

Thanks,

David

View 9 Replies View Related

Simple ALTER Command Setting DEFAULT Help

Apr 21, 2008

Hi all, I am trying to do a very basic ALTER Command and am trying to change its DEFAULT value. Code below is what I currently have:





Code Snippet

ALTER TABLE Table_1

ALTER COLUMN TEST VARCHAR(1000) NULL DEFAULT 2

Thanks, Onam.

*UPDATE* I found this code but are there alternative methods? Additionally, if I was to update its DEFAULT value again how would I go about doing that? Do I first have to remove the CONSTRAINT and then run the command?





Code Snippet

ALTER TABLE Table_1 ADD CONSTRAINT DF_Albumns_Comment DEFAULT 2 FOR TEST

View 8 Replies View Related

Setup And Upgrade :: 2012 - Database Engine Services Failed

Mar 26, 2013

I can't install the SQL Server 2012 Express version with tools downloaded from [URL]

I'm getting the following error: 

Error installing SQL Server Database Engine Services Instance Features
Could not find the Database Engine startup handle.
Error code: 0x851A0019

I'm trying to install a new stand-alone version with a default instance but always getting this error. From the features I'm installing the database engine services (not the replication), all the tools, only the basic management toolds and the SQL Client connectivity SDK.

Further in the installation I'm choosing the Windows authentication and in the list of SQL administrators I've already tried to install as current user but also as System. Both with the same error result.

[URL]

Note: Visual studio is not installed.

View 8 Replies View Related

Backup Failed To Complete The Command Backup Database

Aug 4, 2007

Backup failed to complete the command backup database [ ] TO VIRTUAL DEVICE = ' { 853D3FC0 - 45EA -85B1 - 54F0EA379CAC } 24 ' WITH SNAPSHOT , BUFFERCOUNT = 1 , BLOCKSIZE = 1024

View 1 Replies View Related

SQL 2012 :: Creating Snapshot From Mirror Database Failed - Could Not Redo Log Record

Sep 1, 2015

Process to create snapshot failed (twice per day snapshot of the database is being created for some people to work on). Morning snapshot worked fine but the afternoon one failed. The snapshot is being created from Mirror database. I used this code:

CREATE DATABASE [DB_snapshot] ON
(name = N'DB',filename = N'D:SnapshotDB.SQLSnapshot' )
,(name = N'indexes',filename = N'D:SnapshotDB_indexes.SQLSnapshot' )
AS SNAPSHOT OF DB

And the error message i get

Msg 1823, Level 16, State 6, Line 1
A database snapshot cannot be created because it failed to start.
Msg 1823, Level 16, State 7, Line 1
A database snapshot cannot be created because it failed to start.
Msg 3456, Level 21, State 1, Line 1
Could not redo log record (202011:19306:2), for transaction ID (0:0), on page (1:1823948), allocation unit 281474979397632, database 'DB_snapshot' (database ID 6). Page: LSN = (201954:220201:1), allocation unit = 281474979397632, type = 1. Log: OpCode = 4, context 18, PrevPageLSN: (202010:23679:1). Restore from a backup of the database, or repair the database.
Msg 3313, Level 21, State 1, Line 1

During redoing of a logged operation in database 'DB_snapshot', an error occurred at log record ID (202011:19306:2). Typically, the specific failure is previously logged as an error in the Windows Event Log service. Restore the database from a full backup, or repair the database.

What might be causing this error? Mirroring seems to be working OK. status is "Synchronized"

View 1 Replies View Related

T-SQL (SS2K8) :: MASTER And MSDB - Defrag Using Standard Alter Index Command?

Oct 10, 2014

On a 2008r2 server, I ran the frag utility against master and msdb and noticed they were severely fragmented.

Is it ok to defrag them using the standard Alter Index command?

View 7 Replies View Related

T-SQL (SS2K8) :: Use Variable In ALTER / CREATE PARTITION SCHEME Command For Filegroup?

May 9, 2010

Is it possible to use a variable to specify the filegroup in the ALTER/CREATE PARTITION SCHEME command?

I want the partition scheme to use the default filegroup for ALTER and CREATE PARTITION SCHEME. At the time the script is created, I don't know the default filegroup in the database.

My code:

declare @fileGroupName VARCHAR(50) = (select top 1 name from
sys.filegroups where is_default = 1)
ALTER PARTITION SCHEME MyScheme NEXT USED @fileGroupName

Is failing:

Incorrect syntax near '@fileGroupName'.

Q: Is it possible to use a variable for the filegroup in the ALTER/CREATE commands? Is so, what is the correct syntax?

Q: If using a variable is not possible, is there another way to specify the default filegroup?

View 2 Replies View Related

Alter Failed Trying To Modify Surface Area Configuration Xp_cmdshell - Help Needed

May 9, 2007

I installed SQL Server 2005 Enterprise Edition (64-bit) and then applied SQL SP2. When I launch the "SQL Server 2005 Surface Area Configuration" and choose "Surface Area Configuration for Features" I'm trying to enable xp_cmdshell.

After ticking the checkbox, and clicking Apply, I receive the error below. Anyone have any ideas on how to fix this?







===================================

Alter failed. (Microsoft.SqlServer.Smo)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Alter+Configuration&LinkId=20476

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Smo.ConfigurationBase.Alter(Boolean overrideValueChecking)
at Microsoft.SqlSac.Public.Smo.SetSetting(Credentials credentials, DatabaseFeature feature, Int32 value)
at Microsoft.SqlSac.MainPanel.UserControlSSxp_cmdshell.ProcessOK(HashKey givenKey, String machineName)
at Microsoft.SqlSac.MainPanel.FormFeatures.commitDBChanges()
at Microsoft.SqlSac.MainPanel.FormFeatures.commitChanges()

===================================

Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. (Microsoft.SqlServer.ConnectionInfo)

------------------------------
Program Location:

at Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String query, ExecutionTypes executionType, Int32& statementsToReverse)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(String cmd)
at Microsoft.SqlServer.Management.Smo.ConfigurationBase.DoAlter(Boolean overrideValueChecking)
at Microsoft.SqlServer.Management.Smo.ConfigurationBase.Alter(Boolean overrideValueChecking)

View 7 Replies View Related

Delete Command Failed

Nov 10, 1999

Hi

I am using SQL 6.5. I have a master table which is referenced by more than 35 tables. When I try to
delete a record from the table, i am getting this message

Msg 431, Level 16, State 0
Unable to bind foreign key constraint. Too many tables involved in query.

SQL 6.5 maximum 31 foreign key references. I was wondering is there any way to delete those
records. (i don't want to drop the foreign constraints)

SQL 7.0 supports maximum 63 foreign key references.

Thanks in advance

Moorthy.

View 1 Replies View Related

SQL 2012 :: How To Drop Columns From Alter View

Mar 20, 2015

I have a VIEW which is dynamically generated through complex dynamic SQL. Unfortunately the dynamic SQL uses "Select * from table" to select the columns because the programmer did that to reduce the amount of code in the dynamic SQL string as the code can't be debugged if it's too long.

Therefore, I have a VIEW with columns in it I don't need, and want to remove them from the view - I need to remove all columns with column names matching the syntax '%1%_2' .

The view is called TEMP_EXPORT_1

I can either use the code below to return a list of columns that I want removed:

select column_name from information_schema.columns

where table_name='TEMP_EXPORT_1' and column_name like '%1%_2'

Or I can use the code below to return the list of columns that I want to keep:

select column_name from information_schema.columns

where table_name='TEMP_EXPORT_1' and column_name not like '%1%_2'

Now how would I go about altering TEMP_EXPORT_1 view so that it no longer has these columns? I know views don't have a drop statement...

Therefore I tried the following but I'm not sure of the syntax:

ALTER VIEW dbo.TEMP_EXPORT_1
AS
SELECT (select column_name from information_schema.columns
where table_name='TEMP_EXPORT_1' and column_name not like '%1%_2')
FROM dbo.TEMP_EXPORT_1

Am I on the right track? how can I ALTER this view to remove these columns? ... I want to keep this separate from the code that generated the view as I want it as an optional procedure that can be run if needed.

View 2 Replies View Related

SQL 2012 :: Alter Logical FileName During Restore

Aug 12, 2015

Can two databases have same logical filenames in the same instance?

In my instance, database already exists say A.

I have to restore DB B with the same backup used for database A in the same instance.

So, once the database B is restored, A and B will have same logical fileNames.

Can I leave it as is? Or do i alter only after B is restored?

Or is there a way where I can change the logical file for B while restoring?

View 1 Replies View Related

SQL 2012 :: Permission To Create / Alter Proc But Not DBOwner

Feb 5, 2015

Without giving dbowner how can we grant permission to user to alter/create procs?

View 3 Replies View Related

BACKUP Failed To Complete The Command Sp_prepexec;1

Feb 28, 2007

One of my SQL Servers (SQL 2000 SP4) is reporting this error in the Maintenance Plan. But shortly after it shows this error is does successfully backup my Databases (per log history), however the plan is indicating "failure".

I have no idea how to resolve this nor why it is happening.

Rob.

View 1 Replies View Related

SQL Server 2012 :: Alter Query To Avoid Hard-coding?

May 25, 2015

using below query to raplace the string values (REPLACE abc with T1223), how to use the query without hard coding.

i want to store the values in another temp table and access in main query.

'abc', 'T1223',
'def', 'T456',
'ghi', 'T789',
'jkl', 'T1011',
'mno', 'T12'
select id,name,
LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(name,
'abc', 'T1223'),
'def', 'T456'),
'ghi', 'T789'),
'jkl', 'T1011'),
'mno', 'T12'))) New_id
from TAB

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved