I have a database aspnet-Ebuy-20151210093351. I use the command:
drop database aspnet-Ebuy-20151210093351
to delete it, but I cannot do it, I get an error message:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
You need to escape the database name with brackets, without which SQL Server will interpret the dashes - as being subtraction symbols.
drop database [aspnet-Ebuy-20151210093351]
Have you tried wrapping the table name in Brackets []?
drop database [aspnet-Ebuy-20151210093351]
Related
I want to change the DURABILITY of a memory-optimized table in SQL Server 2016 from SCHEMA_AND_DATA to SCHEMA_ONLY.
The Microsoft documentation suggests that the following ALTER TABLE statement should work:
ALTER TABLE mem_opt_table
DURABILITY = SCHEMA_ONLY
But it gives the following error:
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near 'DURABILITY'.
What is the correct syntax for changing the durability setting on a table? Are there any additional steps that I am missing?
The documentation linked in the original question is faulty as was suggested by many of the comments. That is confirmed in the github issue response here: https://github.com/MicrosoftDocs/sql-docs/issues/3523#issuecomment-554511264.
Therefore, the only way to do this is to drop the table and re-create it with the desired DURABILITY setting.
I created and altered a trigger and everything worked well, but when I started the SQL Server Management Studio later on, the following error appeared:
Msg 2108, Level 15, State 1, Procedure store_110, Line 43
Cannot create trigger on 'IT_ServerDB.dbo.Users' as the target is not in the current database.
Cannot create trigger on 'IT_ServerDB.dbo.Users' as the target is not in the current database.
It seems ,you are using three part naming like below
'IT_ServerDB.dbo.Users
use two part naming
use IT_ServerDB
go
create trigger triggername
on
and rest of syntax
I am trying to run a query in SQL Server 2008. It looks like this:
IF EXISTS (SELECT name FROM sysobjects WHERE name = "Bonds" AND type = 'U')
DROP table Bonds
GO
When I run this, I get this error:
Msg 207, Level 16, State 1, Line 2
Invalid column name 'Bonds'.
Msg 28102, Level 16, State 1, Line 3
This query was created by SQL Server. I am trying to run it in a different computer. Then I face this issue.
I have tried Ctrl+Shift+R as this post: SQL Server Invalid Column name after adding new column. But it is not helping.
Need some guidance on this.
Change
WHERE name = "Bonds"
to
WHERE name = 'Bonds'
Otherwise "Bonds" is treated like a column-name which does not exist.
use single quotes in search condition
WHERE name = 'Bonds'
I think you can also use
SET QUOTED_IDENTIFIER OFF;
before your query.
I need to copy a table from one server to another.for that I have did the below code,
select * into tbls from SNRJDI-32962\xxxmanagement.master.dbo.tbl
When I execute I got error Like,
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '-'.
but this is the actual server name(SNRJDI-32962\xxxmanagement)..Please do needful..
Thank you
You first have to add a linked server from the target server to the source server.
Then you can use a four-part name, separated by dots:
select * into [newtable] from [linked_server].[databasename].dbo.[tablename]
I would add to Andomar's answer that to have special characters in an object name, you need to surround the name in [square brackets] otherwise sql will interpret your "-" as a minus sign
UPDATE:
Running this:
ALTER DATABASE "STRINGSDB.MDF"
COLLATE Latin1_General_CS_AShere
Getting this error:
Msg 5030, Level 16, State 2, Line 1
The database could not be exclusively locked to perform the operation.
Msg 5072, Level 16, State 1, Line 1
ALTER DATABASE failed. The default collation of database 'STRINGSDB.MDF' cannot be set to Latin1_General_CS_AS.
I only have SQL server Management Studio accessing the DB.
ORIGINAL POST:
My SQLEE indicates a Collation of...
COLLATE SQL_Latin1_General_CP1_CS_AS
I am having problems finding the meaning of the CP1, does anyone know what this means?
I also ran...
select * from ::fn_helpcollations()
and the
SQL_Latin1_General_CP1_CS_AS
doesn't exist, also checked...
Latin1_General_CP1_CS_AS
thanks for any help.
From SQL Server Collation Name (Transact-SQL):
CP1 specifies code page 1252