I've developed my website using EF4 and SQL Server 2005, but when moving to the staging site it turns out that they use SQL Server 2000.
Now I'm getting this error, which I believe is related to SQL Server 2000:
Incorrect syntax near '('. 'row_number' is not a recognized function name.
Is there a way of fixing this?
Thanks
EF v4 does not support SQL Server 2000. More details here:
https://connect.microsoft.com/VisualStudio/feedback/details/499186/entity-framework-v2-doesn-t-support-sql-2000
I came across the exact same problem and as per the comments/responses on StackOverflow I had almost given up and flicked it to client to upgrade their database to > 2000 version. Unfortunately that wasn't possible for them due to many other issues. I had to go around googling for a solution and from somewhere I found a work-around.
This is what I did.
Right clicked the ModelName.EDMX file -> Open With
Selected XML (Text) Editor
Found ProviderManifestToken="2005" and replaced it with
ProviderManifestToken="2000"
Published the changes and voila!
Now the reason I'm saying it's a work-around (not a solution) is because
If you update your model from database again and your development
machine database is >= 2000 (which is likely to be a case as SQL
2000 connection is not supported at all by MS according to this
article) this value in the XML will change automatically
Also, the queries generated by EF after this change have worked in
my situation but I cannot guarantee that all the queries ever
generated by your application would work without any problems
Row_Number() returns the sequential number for a each row returned. Are you calling Row_number(), or is the entity framework?
Either way, you may be able to write a user-defined function that re-implements ROW_NUMBER. Stackoverflow post on this here:
ROW_NUMBER Alternative for SQL Server 2000
Not sure this is going to do any good in the long run; you're likely to find that you get around this problem only to encounter the next reason that EF doesn't work on SQL 2000. But, it might be worth the few minutes to try.
Related
My problem is that when I write a query in sql server on a sheet I get intellisense for the first query and only the first.
If I was to write a query directly below the first, I get no intellisense at all. I could put my cursor back to the initial query and get intellisense once again.
For example, this is a single query sheet:
select t.* from table1 t; --Intellisense, yay!
select t.* from table2 t2; --no intellisense, ;(
What is going on here? I have turned off SQLCMD Mode, I read this will mess up the intellisense, also I have changed the maximum script size around - all to no avail.
Any help would be appreciated, thank you!
the problem is SSMS reads the second query as an error. I know you can comment out the top one and get intellisense on the bottom on. Really sucks when you have a huge server.
if you are working on a remote server you as many people that use SSMS 2012 have to wait a patch from Microsoft.
Otherwise here you can find a list of setup to check.
Best regards,
Danny
One possibility - If you have installed Visual Studio 2010 Service Pack 1 then it will definitely break SQL server intellisense. To resolve the issue install the latest service pack for your SQL server. Read this article here - https://support.microsoft.com/en-gb/kb/2531482
Yes, I still have a SQL Server 2000 box (I know, I know . . .). Can someone please remind me the most reliable/safe way to retrieve the latest IDENTITY entry from a newly inserted records from a particular table? I know how to do it in SQL Server 2008, etc, but I cant remember if its different from SQL Server 2000
SCOPE_IDENTITY. http://msdn.microsoft.com/en-us/library/aa259185(v=sql.80).aspx Don't EVER use ##IDENTITY. It should never be used for any reason EVER. Using it will cause you to break out in a rash, your wife to divorce you, and Dr. Who to be cancelled.
See: http://www.sqlfiddle.com/#!3/2e2d3/4 Behold the Heart of Darkness! Behold the evil that is ##IDENTITY! Use ##IDENTITY and lose your own!
EDIT2: Found a fix! I used the number of the desired schema instead of the name. Should've thought of that before, really! And i think the error messages could've been a bit better aswell. Thanks for all your time!
How can i get the names of all tables inside a database through sql inside asp classic?
The server is running windows 2008, iis7.5 and microsoft jet. I've tried all the querys i could find on the internet (and here) but none have worked.
If i add a ; to the query to run a set of querys at the same time it gives me an error because the statement isn't over at the semicolon.
The master.mdf database cannot be accessed because it's of unknown format.
The sysobjects variable apparently doesn't exist.
I am using mssql 2000 format. (.mdf)
The connection is made through classic asp with the Microsoft.Jet.OLEDB.4.0 provider and ADODB connection/recordset.
How do I get list of all tables in a database using TSQL?
Query to get the names of all tables in SQL Server 2008 Database
EDIT:
I've found two folders containing databases. One is in C:\program files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\mssql\binn\templates and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, msdbdata.mdf and msdblog.ldf. The other one is also in the \binn\template data directory and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, MSDBData.mdf, MSDBLog.ldf, mssqlsystemresource.ldf, mssqlsystemresource.mdf, tempdb.mdf and templog.ldf. Maybe these is of some interest?
How can i tell if i have permission? Does it give a permission denied error?
Please help! No, don't. Read the 2nd edit at the top.
USE YOUR_DATABASE
GO
SELECT *
FROM sys.Tables
GO
Have you tried the example from:
http://www.kamath.com/codelibrary/cl002_listtables.asp
I almost always use the INFORMATION_SCHEMA views:
SELECT * FROM INFORMATION_SCHEMA.TABLES
If this isn't working for you, the SQL user your site is running under may not have access to the system objects. This is actually a good thing, as giving your site access to the underlying database schema can leave you vulnerable to SQL injection.
So if you do go this route, proceed with caution.
The mdf by itself is useless: you need a database engine (a.k.a. a SQL Server instance) to "run" it. As I understand the question, this is your problem.
Then you can use sysobjects in your database: unless you have added your tables to the master database
There is no practical way to use an mdf directly: if nothing else download MSDE
I have been working on migrating some of our data from Microsoft SQL Server 2000 to 2008. Among the usual hiccups and whatnot, I’ve run across something strange. Linked below is a SQL query that returns very quickly under 2000, but takes 20 minutes under 2008. I have read quite a bit on upgrading SQL server and went down the usual paths of checking indexes, statistics, etc. before coming to the conclusion that the following statement, found in the WHERE clause, causes the execution plan for the steps that follow this statement to change dramatically:
And (
#bOnlyUnmatched = 0 -- offending line
Or Not Exists(
The SQL statements and execution plans are linked below.
A coworker was able to rewrite a portion of the WHERE clause using a CASE statement, which seems to “trick” the optimizer into using a better execution plan. The version with the CASE statement is also contained in the linked archive.
I’d like to see if someone has an explanation as to why this is happening and if there may be a more elegant solution than using a CASE statement. While we can work around this specific issue, I’d like to have a broader understanding of what is happening to ensure the rest of the migration is as painless as possible.
Zip file with SQL statements and XML execution plans
Thanks in advance!
We experienced similar problems a few years back in our migration from 2000 to 2005. The error we were seeing was actually an invalid cast error. I think I found the thread here
The query optimiser has much more freedom in SQL Server >=2005. The CASE solution is probably the best route.
This is the second time it happens to me and before modifying a 3rd party Database structure I wanted to know if anyone knew a better solution:
I'm accessing a MS SQL Server 2008 from a Lotus Notes Agent (Notes 7) to retrieve some data. I use LSXODBC and my "Select" statement works perfect... Except that my agent cannot "understand" Nvarchar SQL Field types. Any other data types work ok (can get the values from number and dates fields without a problem).
It took me a while to figure it out, and I couldn't find a solution (other than modifying the field types on the SQL table to Varchar instead of nVarchar)
I could replicate this both in MS SQL 2005 and 2008.
Last "elegant" solution was to create an SQL view -instead of modifying table structure- with the varchar types instead of nvarchar. Works ok but I have to create a view for each table I'm retrieving data from.
I tried to set the Field type using FieldExpectedDataType Method but didn't work. Still got a DB_TYPE_UNDEFINED.
I thought there might be some configuration issues? or maybe I'm using an old LN Version / ODBC Driver version?
Any hint would be greatly appreciated.
Thank you in advance.
Diego
An old ODBC driver may not support unicode. It was not added until SQL Server 2000 (I'm fairly sure)