Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Monday, March 12, 2012

help needed to drop a table!!!

hi,

can any one tell me how to drop a table...i tried to delete using the command :

drop table sample;

but it displays an error stating that,

Cannot drop the table 'dbo.sample', because it does not exist or you do not have permission.

pls post the reply asap

-Sweety

To verify that the table does indeed exists, try:

SET ROWCOUNT 1
SELECT * FROM MyTable
SET ROWCOUNT 0

Then if you receive data, and the statement DROP TABLE MyTable again fails, check your permissions. It is possible that your login does not have permission to remove a table.

|||

Make sure you're using the correct db.

USE MyTest
GO
DROP TABLE Test

Adamus

|||

check whether the table exists in the db at all... if exists , see who owns it.... give fully qualified name.

in SQL 2005

select Name from Sys.Objects where name='tablename'

Drop table databasename.schema.Tablename

SQL 2000

select Name from SysObjects where name='tablename'

Drop Table databasename.owner.Tablename

Madhu

|||

May be that table actually does not exist

|||

sweet_salt wrote:

hi,

can any one tell me how to drop a table...i tried to delete using the command :

drop table sample;

but it displays an error stating that,

Cannot drop the table 'dbo.sample', because it does not exist or you do not have permission.

pls post the reply asap

-Sweety

Check that the account that you are using to run this query has the appropriate permission to do so.

Check the user properties in the security node.

Friday, March 9, 2012

help needed for Recovring database

I wanted to move my database log file to another drive, but unfortunately I
executed wrong command .
alter database ABC modify file
(name = 'ABC_log',filename= 'D:\Program Files\Microsoft SQL
Server\MSSQL\data\ABC_log.LDF')
instead of
alter database ABC2 modify file
(name = 'ABC2_log',filename= 'D:\Program Files\Microsoft SQL
Server\MSSQL\data\ABC2_log.LDF')
After this, I found my database in Suspect mode, so I executed these commands
sp_configure 'allow updates', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_resetstatus 'ABC2'
And restarted DB services, but database was still in suspect mode, after
checking every possibility, I detached that database, I don’t know why I did
this.
But now I am not able to attach database back. When I try doing this it’s
give me following error
Error 5173: Cannot associate files with different databases.
By the way when I attach this mdf file, it changes the logical file name to
ABC_Data.mdf
But when I execute following query, it displays different logical file name
with ABC.mdf
dbcc checkprimaryfile (N'D:\Program Files\Microsoft SQL
Server\MSSQL\Data\ABC2.mdf', 3)
I believe if I change this logical file name I’ll be able to attach database
back.
Kindly help me the recovering database.
Note: I do not have the transaction log backup & current DB backup.
Farhan Iqbal
Error 5173 means, you are trying to attach files that belong to another
database. Check the file names that you are using for your attach.
"Farhan" <Farhan@.discussions.microsoft.com> wrote in message
news:89333AE6-EE72-4863-A73B-C9419112318C@.microsoft.com...
>I wanted to move my database log file to another drive, but unfortunately I
> executed wrong command .
> alter database ABC modify file
> (name = 'ABC_log',filename= 'D:\Program Files\Microsoft SQL
> Server\MSSQL\data\ABC_log.LDF')
> instead of
> alter database ABC2 modify file
> (name = 'ABC2_log',filename= 'D:\Program Files\Microsoft SQL
> Server\MSSQL\data\ABC2_log.LDF')
>
> After this, I found my database in Suspect mode, so I executed these
> commands
> sp_configure 'allow updates', 1
> GO
> RECONFIGURE WITH OVERRIDE
> GO
> EXEC sp_resetstatus 'ABC2'
> And restarted DB services, but database was still in suspect mode, after
> checking every possibility, I detached that database, I don't know why I
> did
> this.
> But now I am not able to attach database back. When I try doing this it's
> give me following error
> Error 5173: Cannot associate files with different databases.
> By the way when I attach this mdf file, it changes the logical file name
> to
> ABC_Data.mdf
> But when I execute following query, it displays different logical file
> name
> with ABC.mdf
> dbcc checkprimaryfile (N'D:\Program Files\Microsoft SQL
> Server\MSSQL\Data\ABC2.mdf', 3)
> I believe if I change this logical file name I'll be able to attach
> database
> back.
> Kindly help me the recovering database.
> Note: I do not have the transaction log backup & current DB backup.
> Farhan Iqbal
>

Sunday, February 19, 2012

Help me please i have a problem in ALTER command

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

Try this:

ALTER TABLE TranPay ALTER COLUMN TranKey int IDENTITY(1,1)

You must specify the column data type.|||

Try this:

Code Snippet

ALTER TABLE TranPay ADD TranKey int IDENTITY (1,1)