I'm trying to get the version of SQL Server 2008 and above version using WMI, I'm using the class of ComputerManagement10 and the query of
select PropertyStrValue
from SqlServiceAdvancedProperty
where PropertyName = \'VERSION\' and ServiceName =\'MSSQL$SQL2008R2SP1'\'
where ServiceName is the instance of the SQL Server.
I experience a strange problem that the expected result (PropertyStrValue field) I get is different from the regular select ##version or the "Right click -> Properties" (of sqlservr.exe)
The version WMI gets is "10.51.2500.0" while the original one is "10.50.2500.0"
I checked more than twice to be sure that this is the correct instance, SQL Server, host, etc, but it seems that I am not the only one who experienced this sort of thing.
Does anyone know why is this behavior happening and how to fix it ?
Does anyone know if it's reliable to use WMI to retrieve the version of SQL Server ?
Thanks in advance.
I can't comment on using WMI, but the value from select ##version or better select SERVERPROPERTY('ProductVersion') is correct
Also, are you doing this correctly in the first place?
I want to know the version of SQL Server in my application and your query is useful.
I get the same error !
I find this if you find anything :
Wrong SQL Version
Apparently just an error, but it's good for me
SQL Version list
10.50 / 10.51 => 2008 R2
10.00 => 2008
Related
SUSER_SID has two optional parameters. I am using only first 'login'. Documentation for it applies to Azure SQL Database, but it doesn't work. For 'login' parameter is says "Applies to: SQL Server 2008 and later".
When I call SELECT SUSER_SID('test');
using SSMS, I get the error:
'SUSER_SID' cannot be invoked with parameters in this version of SQL Server.
I am using Azure SQL Server ver. 12.0.2000.8
How is that possible, what am I missing?
Odd, this isn't actually documented but I get the same problem. (Will raise this on the document's GitHub).
If you want the sid you could use sys.database_principals instead:
SELECT dp.sid
FROM sys.database_principals dp
WHERE dp.name = N'test';
for this question I asked Azure Support. They told me that:
Based on the online document, the parameter “login” applies to SQL Server 2008 and later version, and the parameter2 applies to SQL Server 2012 and later version. That is the reason why we will get the error message “'SUSER_SID' cannot be invoked with parameters in this version of SQL Server.” while running the command SELECT SUSER_SID('serveradmin') , because Azure SQL database does not support SUSER_SID() with parameters.
If you want to check the SID, please consider running the command in below instead:
select name, sid from sys.sql_logins where name = 'test'
Here's the screenshots:
Hope this helps.
print2
I've tried every possible way to get the ID of the object through OBJECT_ID() but it seems like i can only find the object searching it manually in 'sys.objects'. In SQL 2008 it works just fine, same code. I'm using SQL Server 2017 in the picture.
Does anyone know if this is a problem with SQL Server 2014? Am I missing something?
object_id('tempdb..#some_name') will only return a NOT NULL result if the temp table was created in the same session.
It looks as though it was created by a different connection.
For your use case (commented out) you can just do
DROP TABLE IF EXISTS #some_name
Anyway if you are on SQL Server 2017 as stated.
But the screenshot shows 12.0.2000 which is SQL Server 2014 so that won't work on that version.
I use SQL Server 2012 and I have some databases on it. The problem is I suddenly get an error saying,
object reference not set to an instance of an object
I get this error when:
Going to write a new query
Select previously entered data by right click the table name ->
Select top 1000 rows
What I can do without getting error message:
Log into my instance successfully using both Windows Authentication mode and SQL Authentication mode.
Edit the table data by right click the table name -> Edit top 200 rows
Create a new database
I'm using:
Microsoft SQL Server Management Studio: 11.0.3128.0
Microsoft .NET Framework: 4.0.30319.34014
Operating System: Windows 8.1
Here are some snapshots of the error.
Please give me a solution to fix this problem. Your help will be highly appreciated.
I fixed the problem by running SSMS as administrator.
I could solve the error.
Repair the SQL Server.
Go to Add/remove programs Microsoft SQL Server 2012(x64) -> Uninstall/Change -> Repair.
Select the instance that you want to repair here.
For me, after repairing the instance, the error was solved.
Thanks for all who spent their valuable time to reply my question.
I got the same error message. Problem was 0 bytes free on the C: drive.
Its may be late, but i get the same error in SQL SERVER 2016, i resolved it by assigning full access to the back up folder.
I faced the same error once in my project. This is purely due to SSMS(sql client) is corrupted. Just for cross check that server is fine and client is corrupted, try to connect to the sql-server in this machine from any other server if you have access and query the tables. If it returns data, just uninstall and reinstall the client(ssms) to solve the issue
Thanks
I got the same error for SQL 2016 and the only solution for me was to completely uninstall (in appwiz.cpl) all entries Visual Studio + SQL. Then I executed VisualStudioUninstaller and I reinstalled SQL and after Visual Studio.
I got the same message when I try to alter table to add new column . Issue is I haven't enclosed data types using '[' datatype ']' . Its Real data type. But It got fixed when I enclosed in using square braces.
My solution for this was to extract the csv file with the python library pandas rather than saving it with Excel. Further, I removed columns that I didn't need as a few columns caused formatting errors during the import.
For those who are unable to modify their SQL configuration due to administrative restrictions at work:
I was able to open a new query page by creating a SQL Server Scripts project and adding a new query through the solution explorer
I got the message after deleting a database. The database was gone, so I moved on.
I am using SQL Server 2008 R2. It is working fine. But recently, I have changed my hosting server and I came to know that they have installed SQL Server 2012 on Server.
Now, Issue is that after connecting with Server Database through SQL Server 2008 R2, When I click on any table name or Stored Procedure, I am getting error : Index was outside the bounds of the array. (Microsoft.SqlServer.smo)
So, is there any issue from my side or It is from Server Side ??? and How can I prevent this issue ?
Restarting the Management Studio worked for me.
Upgrade your SqlServer management studio from 2008 to 2012
Or
Download the service packs of SqlServer Management Studio and update probably resolve you solution
You can download the SQL Server Management studio 2012 from below link
Microsoft® SQL Server® 2012 Express http://www.microsoft.com/en-us/download/details.aspx?id=29062
For me this problem still exists with SSMS version 2016 (13.0.16100.1).
A decent workaround is to not use the 'Right click' -> 'Add table...' dialog, but simply drag the table you want to add from the Object Explorer, onto the Diagram surface. While dragging the mouse icon changes into an 'add' symbol and the table is added when you release the mouse.
Beats having to close SSMS every time.
Restarted worked!
I found the same error to add new table to my database diagram on sql server 2016, restarted sql server management studio, finally solved.
This is an issue if you are using 2008 management studio tools to connect to a SQL 2012 instance.
I experience this a lot if I am working on one server with SQL 2008, and trying to quickly query another server that is running SQL 2012.
I normally keep my personal workstation on the latest version of management studio (2012 in this case), and am able to administer all servers from there.
The Reason behind the error message is that SQL couldn't show new features in your old SQL server version.
Please upgrade your client SQL version to same as your server Sql version
Solution: Ignore the error
Just to show that the error does not do much in SSMS version 18.9.2, drag the table to be shown in the diagram from the Object Explorer tab and wait for it to finish loading before you start using it.
The suggested causes are now proven to be mostly impossible. I'm running SSMS V17.9.2 against SS 2014 and still have the problem. Memory problems have existed with this tool since at least 2006 when I started using SSMS.
Yes, MS 'wants' to get rid of diagramming but users won't let them. I have a feeling they will never fix any of these issues because they want users to be so fed up with the tool that enough of them quit using it and they can abandon it entirely.
Restarting is still a workaround if you can stand doing so numerous times per day.
you must use new version of Management Studio. And also you will got an error 29506. so you should run as Administrator for setup.
Look this site.
http://shareis.com/post/29506-management-studio-express
I had a similar experience with using SMO via C# with the stack trace:
[1896] System.IndexOutOfRangeException: Index was outside the bounds of the array.
[1896] at Microsoft.SqlServer.Management.Smo.BitStorage.SetBit(Int32 itemIndex, BitIndex bitIndex, Boolean value)
[1896] at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddObjectPropsFromDataReader(IDataReader reader, Boolean skipIfDirty, Int32 startColIdx, Int32 endColIdx)
[1896] at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ImplInitialize(String[] fields, OrderBy[] orderby)
[1896] at Microsoft.SqlServer.Management.Smo.SqlSmoObject.Initialize(Boolean allProperties)
[1896] at Microsoft.SqlServer.Management.Smo.SqlSmoObject.OnPropertyMissing(String propname, Boolean useDefaultValue)
[1896] at Microsoft.SqlServer.Management.Smo.PropertyCollection.RetrieveProperty(Int32 index, Boolean useDefaultOnMissingValue)
[1896] at Microsoft.SqlServer.Management.Smo.PropertyCollection.GetValueWithNullReplacement(String propertyName, Boolean throwOnNullValue, Boolean useDefaultOnMissingValue)
[1896] at Microsoft.SqlServer.Management.Smo.Information.get_MasterDBPath()
It turned out my versions of the CLR/NCLI/SMO were 10.50.1600.1.
Upgrading them to 10.53.6000.34 fixed it - thus allowing the 2008R2 SMO to do many things with 2012 and 2014 servers.
Get them from the feature pack
https://www.microsoft.com/en-gb/download/details.aspx?id=44272
I found an issue with Diagram and Schema in SQL-Server 2016 that could be useful to the subject.
I was editing diagram (related to, and with lot of tables of, the "sales" schema) and added a new table, BUT forgot to declare it schema, so it was with the default "dbo". Then when I returned to, and opened up, the schema "sales" and tried to add an existent table... Bluf! THAT Triggered exactly the same error described in that thread.
I even tried the workaround (drag the table) but it didn't work. Suddenly I noticed that the schema was incorrect, I updated it, tried again, and Eureka! the problem was immediately away... Regards.
It's very old problem with cashed content. MS planning to remove diagrams from SSMS, so they don't care about this. Anyway, solution exists.
Just close Diagrams tab and open it again. Works with SSMS 18.2.
You have to use latest version with SSMS
You can check latest builds via this page
https://sqlserverbuilds.blogspot.com/
I just upgraded my SSMS to 2008 R2. I'm missing the option to select the top 1000 rows from a table, like this:
Mine looks like this:
I know how to change the number of rows that are displayed, but the options aren't there at all. I saw that someone submitted a bug for this a few years ago, but there was no workaround, and I'm not sure what to do. Any ideas?
EDIT - Azure Problem?
I just used SSMS to open my local SQL Server, and I get the option to select the top 100 rows. But in my other SSMS instance, the one that is connected to my Azure DB, I don't see it. Is it possibly an Azure limitation?
Based on this answer, I believe it is a limitation of SQL Azure. I have not been able to find any additional information that would allow you to work around the issue.
As of 06/04/2015 MS has published a hotfix to solve this issue.
http://support.microsoft.com/en-us/kb/3011055
"An update is available that enables "Select Top 1000 Rows" option for tables and views of SQL Azure database"
You do not have this option in SSMS while working with SQL Azure, you have to exexute the query yourself ... select top 10000 from tablename
There are few other options as well in SSMS which are not displayed in case of SQL Azure.
This is an excpected behaviour for SQL Azure.
It is now available on SqlServer Mgt Studio 2014.
Check that you have correct values in the SQL Server Object Explorer Settings: