I am creating a database by using following schema ...... using microsoft sql server....
CREATE DATABASE /*!32312 IF NOT EXISTS*/`stacks`/*!40100
DEFAULT CHARACTER SET utf8 */;(Line 15)
USE `stacks`;
/*Table structure for table `answers` */
Got An error like this ...while executing , i dont know....
Error : Msg 102, Level 15, State 1, Line 15
Incorrect syntax near '`'.
would any one pls help on this.....
Many Thanks in advance ....
Did you look up SQL Server CREATE DATABASE and identifier syntax?
All you need is CREATE DATABASE stacks;
Your code is for MySQL
It looks like your syntax is from MySQL. Why do you have back-ticks and "default character set"? This is not SQL Server syntax. Please see the SQL Server docs for CREATE DATABASE: http://msdn.microsoft.com/en-us/library/ms176061.aspx
Related
I have a function that returns a table that will need to be called remotely. Since this functionality is not supported by SQL at the moment, I will need to utilize OPENQUERY to do the following
OPENQUERY([Linked_Server],'Query')
However, I keep getting a syntax error when I put in the ip address for the linked server. Linked server is setup properly from the looks of it. I am getting the following error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'OPENQUERY'.
The script is:
OPENQUERY('NN.NNN.N.NN','SELECT * FROM dbo.DBarBillers')
(where N's are the digits of the defined linked server's IP address).
Intellisense is putting the red line under OPENQUERY and the linked server argument
I have tried unquoting the ip address, and bracing it instead of quoting and all are yielding errors. Thoughts?
You need to select from the openquery so the syntax is
SELECT * FROM OPENQUERY([Linked_Server],'SELECT * FROM dbo.DBarBillers')
The following SQL statement fails on SQL Server 2012(SP1) 11.0.3401.0 Version
DECLARE #b VARCHAR(10) = '12312.2'
SELECT TRY_CONVERT(DECIMAL(10,2),#b)
error message
Msg 195, Level 15, State 10, Line 2
'DECIMAL' is not a recognized built-in function name.
But works fine on SQL Server 2012(SP1) 11.0.3393.0
Both servers have no problem with TRY_PARSE()
DECLARE #b VARCHAR(10) = '12312.2'
SELECT TRY_PARSE(#b AS DECIMAL(10,2))
Update:
after further testing and trying conversion to different types got another different error message
DECLARE #b VARCHAR(10) = '12312'
SELECT TRY_CONVERT(INT,#b)
Error:
error: Msg 195, Level 15, State 10, Line 2
'TRY_CONVERT' is not a recognized built-in function name.
So original error message was miss leading, but now I'm even more confused why it is not there.
Check that the database compatibility level for the particular database you are using the function in is set to SQL Server 2012 (110) under properties/options/compatibility level for the database.
Make sure that you have specified on which database you want to run the query on.
use [Database_Name]
go
>>>>query here <<<
go
In my case I had a number of different databases on the server with different compatibility levels.
You can run the following script to Upgrade your database compatibility level to SQL Server 2012 (110):
if (SELECT compatibility_level FROM sys.databases WHERE name = '[Your_Database_Name]')<120
begin
ALTER DATABASE StreamNet
SET COMPATIBILITY_LEVEL= 110
end
Note: Replace [Your_Database_Name] with your current database name.
Reference: See Microsoft solution for more details
Try another IDE or environment to see if isolates the error? I was getting this error running a query in Azure Data Studio. When I ran the same query in SQL Server Management Studio -- where I'd first written it -- it ran successfully.
I have what I think should be a simple question but for the life of me cannot solve it myself. I'm just trying to do a simple search on a table.
Select *
From dbo.Case
Where dbo.Case.CountyName='Milwaukee'
I keep getting this error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'Case'.
I've also tried taking off the "dbo" and it still does not work.
What am I doing wrong? (Using SQL Server 2008)
CASE is a reserved keyword. You will need to enclose it in [] to use as a an identifier such as a database, column, or table name:
Select *
From dbo.[Case]
Where dbo.[Case].CountyName='Milwaukee'
Case is a reserved word in SQL, so you need to put square brackets around it.
I've been using the code below:
CREATE DATABASE [NSFKIPRODDB01_BKBK] AS COPY OF [NSFKIPRODDB01] (EDITION='BUSINESS', MAXSIZE = 10GB)
But it keeps on throwing me the error below:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'AS'.
Can I ask why isn't a CREATE DATABASE AS COPY OF + ALTER DATABASE good enough?
I have a database of 40 tables. I want to track the changes and keep record of every change made in database. what would be best option ?
Note: i am using MS SQL Server 2005.
i have tried following code for Change Tracking
ALTER DATABASE Customer
SET CHANGE_TRACKING = ON
(AUTO_CLEANUP = ON , CHANGE_RETENTION = 5 DAYS)
but gives error
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'ON'.
if anyone could help me on this issue, i would be greatful.
You might give C2 auditing a try: http://msdn.microsoft.com/en-us/library/ms187634%28SQL.90%29.aspx
I believe you are trying to use a 2008 feature.