This script parses the @@VERSION global variable into individual columns.
I developed it because I wanted to be able gather standard info on all versions.
I know there are functions for a lot of this, but only starting with SQL 2000.
It seems to work with all versions of SQL Server from 7.0 through 2005.
I haven't tested with 6.5 and before or 2008, because I don't have either available.
Please report any problems you see.
Edit: 2007-7-31
1. Changed SQL_SERVER_MAJOR_VERSION to varchar(20)
2. Added code to create a view named V_SQL_SERVER_VERSION
3. Added four new columns to the view:
SERVER_NAME, value from @@servername
SQL_SERVER_MAJOR_VERSION_NUMBER, Example: 9
SQL_SERVER_VERSION_NUMBER, Example: 8.0020390000
WINDOWS_VERSION_NAME, Example: 'Windows 2000'
Edit: 2007-8-2
Changed SQL_SERVER_MAJOR_VERSION to varchar(40)
from
(
select
zz = stuff(yy,charindex(Char(10),yy),1,'#3#')
from
(
select
yy = stuff(xx,charindex(Char(10),xx),1,'#2#')
from
(
select
xx =stuff(VERSION ,charindex(Char(10),VERSION),1,'#1#')
from
(
select VERSION = @@VERSION
) a ) a1 ) a2 ) a3 ) a4 ) a4
Results:
SQL_SERVER_MAJOR_VERSION SQL_SERVER_VERSION SQL_SERVER_PLATFORM SQL_SERVER_EDITION WINDOWS_VERSION WINDOWS_BUILD WINDOWS_SERVICE_PACK
------------------------ -------------------- -------------------- ------------------------------ -------------------- -------------------- ------------------------------
2000 8.00.2039 Intel X86 Standard Edition Windows NT 5.0 Build 2195 Service Pack 4
(1 row(s) affected)
drop view [dbo].[V_SQL_SERVER_VERSION]
go
create view [dbo].[V_SQL_SERVER_VERSION]
as
select
SERVER_NAME = @@servername,
SQL_SERVER_MAJOR_VERSION,
SQL_SERVER_VERSION,
SQL_SERVER_MAJOR_VERSION_NUMBER =
convert(int,floor(convert(numeric(20,10),substring(SQL_SERVER_VERSION,1,4)))),
SQL_SERVER_VERSION_NUMBER=
convert(numeric(20,10),(
convert(numeric(20,10),substring(SQL_SERVER_VERSION,1,4))*1000000+
convert(numeric(20,10),substring(SQL_SERVER_VERSION,6,30)))/1000000),
SQL_SERVER_PLATFORM,
SQL_SERVER_EDITION,
WINDOWS_VERSION_NAME =
convert(varchar(20),
case
when WINDOWS_VERSION = 'Windows NT 5.0'
then 'Windows 2000'
when WINDOWS_VERSION = 'Windows NT 5.1'
then 'Windows XP'
when WINDOWS_VERSION = 'Windows NT 5.2'
then 'Windows 2003'
else WINDOWS_VERSION
end),
WINDOWS_VERSION,
WINDOWS_BUILD,
WINDOWS_SERVICE_PACK
from
(
select
SQL_SERVER_MAJOR_VERSION =
convert(varchar(40),substring(L1,1,L1_BREAK_1-1)),
SQL_SERVER_VERSION =
convert(varchar(20),substring(L1,L1_BREAK_1+3,L1_BREAK_2-(L1_BREAK_1+3))),
SQL_SERVER_PLATFORM =
convert(varchar(20),substring(L1,L1_BREAK_2+2,L1_BREAK_3-(L1_BREAK_2+2))),
SQL_SERVER_EDITION =
convert(varchar(30),substring(L4,1,L4_BREAK_1-1)),
WINDOWS_VERSION =
convert(varchar(20),substring(L4,L4_BREAK_1+4,L4_BREAK_2-(L4_BREAK_1+4))),
WINDOWS_BUILD =
convert(varchar(20),substring(L4,L4_BREAK_2+2,L4_BREAK_3-(L4_BREAK_2+2))),
WINDOWS_SERVICE_PACK =
convert(varchar(30),substring(L4,L4_BREAK_3+2,L4_BREAK_4-(L4_BREAK_3+2))),
VERSION = VERSION
from
(
select
VERSION,
L1_BREAK_1 = charindex(' - ',L1),
L1_BREAK_2 = charindex(' (',L1),
L1_BREAK_3 = charindex(')',L1),
L4_BREAK_1 = charindex(' on Windows',L4),
L4_BREAK_2 = charindex(' (',L4),
L4_BREAK_3 = charindex(': ',L4),
L4_BREAK_4 = charindex(')',L4),
L1,
L4
from
(
select
VERSION,
L1 =
convert(varchar(100),
rtrim(ltrim(replace(substring(zz,1,charindex('#1#',zz)-1),'Microsoft SQL Server','')))
) ,
L4 = rtrim(ltrim(substring(zz,charindex('#3#',zz)+4,100)))
from
(
select
VERSION,
zz = stuff(yy,charindex(Char(10),yy),1,'#3#')
from
(
select
VERSION,
yy = stuff(xx,charindex(Char(10),xx),1,'#2#')
from
(
select
VERSION,
xx =stuff(VERSION ,charindex(Char(10),VERSION),1,'#1#')
from
( select VERSION = @@version ) a ) a1 ) a2 ) a3 ) a4 ) a4 ) a5
go
grant select on [dbo].[V_SQL_SERVER_VERSION] to public
go
Is there any way to restore a database of higher version to lower version.
E.g. I have created a database in sql server 2012, created some tables & procedures in that.I took Full backup of that database. Can I restore it to sql 2008r2 or any lower version.
I know direct restore is not possible, I have to use either import or export option or generating script,but i want to know is there any easy step to do so.
Since some analysis services features are only available in Enterprise version , I have to upgrade my SQL 2005 server from standard edition to enterpise edition.
So I uninstall originial standard version of analysis service and install a Enterprise version. However, the analysis service is still a standard version after installation.
Is it possible to keep data engine as standard version and install a enterprise version of analysis service?
Hello,I have been searching and reading a lots of information on the microsoft website about the different version of SQL server, but still can not make my decision.In term of performance, is there a real big difference between the workgroup and the standard version? The workgroup is limited to 3 GB of RAM while the standard is unlimited, would that really change the performance if my server has 16Gb or RAM?The price difference is pretty substantial so if could only have to buy the workgroup , it would be better.One more question, regarding the type of licence, my server has 2 processors, could I avoid buying 2 licences and get the Server plus CAL instead. I am using this server to host 4 web-application running on SQL server. Each database is about 15 MB.Thanks in adavance for your advises.Arno
I am wondering if it is possible to change from SQL Server Enterprise Evaluation Version to Developer Version. The reason is because the Enterprise Evaluation version expires after 180 days. So if I create reports and cubes in Enterprise Evaluation I can import them into Developer Edition right? Should I remove the Enterprise Evaluation version after 180 days or leave it then install Developer Edition?
I have tried to attatch a database ,created by SQL server Express within a C# application , in SQL server 2005 Enterprise edition, but the following error message appears:
-----------------------------
TITLE: Microsoft SQL Server Management Studio ------------------------------
Attach database failed for Server 'MEDO'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft SQL Server&ProdVer=9.00.1187.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach database+Server&LinkId=20476
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The database 'E:X.MDF' cannot be opened because it is version 611. This server supports version 607 and earlier. A downgrade path is not supported. Could not open new database 'E:X.MDF'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)
------------------------------
so , how can I solve this problem , I need to reed the data resides in the tables of 'X' database , how can I do it?? please help me.
I have an ssis package that downloads a SQL Server 2000 database and restores it to a SQL 2005 server. Ninety-five percent of the time it runs just fine, but every so often the job fails and I get the following set of error messages in the log file. (I have had to delete some of the proprietary information for this message to satisfy my boss like putting in [Database name] in place of the actual name of the database in the error message).
OnError, Restore backup file to DB,,,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,Converting database [Database name] from version 539 to the current version 611. OnError,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,Converting database [Database name] from version 539 to the current version 611. OnError,Restore backup file to DB,,,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,Database [Database name] running the upgrade step from version 539 to version 551. OnError,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,Database [Database name] running the upgrade step from version 539 to version 551. OnError,Restore backup file to DB,,,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,The transaction log for database [Database name] is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases OnError,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,The transaction log for database [Database name] is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases OnError,SQL5,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,RESTORE could not start database [Database name]. OnError,SQL5,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,RESTORE could not start database [Database name]. OnError,SQL5,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,-1073548784,0x,Executing the query "RESTORE DATABASE [Database name] FROM DISK = '[Path to back up file]' WITH REPLACE, MOVE 'ASP_Live_Data' TO [Path to MDF file], MOVE 'ASP_Live_Log' TO [Path to LDF file]" failed with the following error: "RESTORE DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. OnError,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,-1073548784,0x,Executing the query "RESTORE DATABASE [Database name] FROM DISK = '[Path to backup file]' WITH REPLACE, MOVE 'ASP_Live_Data' TO [Path to MDF file]', MOVE 'ASP_Live_Log' TO [Path to LDF file]" failed with the following error: "RESTORE DATABASE is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. OnTaskFailed,Restore backup file to DB,,,1/6/2008 2:59:31 AM,1/6/2008 2:59:31 AM,0,0x,(null)
I have received the error message "Package migration from version 8 to version 6 failed".I have developed a SSIS package with Visual Studio 2013 which gives me PackageFormatVersion of 8. I then deploy my package to the ssisdb catalog that is running on a SQL Server 2012, this works fine but when I try to execute the package the error arises…due to SQL Server 2012 has a PackageFormatVersion of 6 and it can’t run something that has a greater version.I haven’t seen any good solution for this but one that would work for me would be to upgrade the Integration Services Server from 2012 to 2014, leaving everything else in 2012 (database, ssms, ssas, ssrs).Would this solve the package format problem? Would I then be able to execute my packages in the ssisdb catalog?
Now, I checked and verified that my backup version of SQL Server is the same as the version installed on the computer I'm restoring too.
I have SQL Server on a production machine that I backed up and want to test a full restore on a dev machine to make sure it will work when I need it to.
Now that I've run the restore command on my tape backup and go to restart the SQL server service I receive:
Configuration block version 0 is not a valid version number. SQL Server is exiting. Restore the master database or reinstall.
I'm afraid I don't understand why this is happening. If the builds are the same, then shouldn't restoring the MASTER database have worked normally and I'd be able to restart the service now?
I have the trial version of SQL Server 2005 installed and have setup a couple of databases. This trial version will expire in another few weeks. I recently purchased a copy of the software and want to install it. Will I lose my databases, user info, etc? How do I go about installing without losing anything?
We have a 64bit os machine that we accidently loaded the 32 bit version of sql server on. We now want to upgrade it to 64 bit sql server, but we now have a production database on it. My understanding is that all I have to do is detach the production database, upgrade to 64bit sql server, then reattach the database. Is this really all I have to do?
I started this thread as the last attempt to sort the issue out.
I have an SSIS package that loads data from a .csv file into my database. It works fine on my developer machine. I start it programmatically or from Management Studio or from Visual Studio, and it works. Then I deploy it to the MSDB database on the computer on which it will have its final place. There again I can start it from Management Studio or from Visual Studio (using the source file), and it works. But when I start it programmatically, it just fails telling me:
Package Warnings: Package Errors: The version of component "****" (11773) is not compatible with this version of the DataFlow. Component "component "Derived Column" (13627)" could not be created and returned error code 0x80070005. Make sure that the component is registered correctly. The component is missing, not registered, not upgradeable, or missing required interfaces. The contact information for this component is "Flat File Source;Microsoft Corporation;Microsoft SqlServer v9; (C) 2005 Microsoft Corporation; All Rights Reserved; http://www.microsoft.com/sql/support;1". component "Agreement File" (11773) failed validation and returned error code 0xC0048021. One or more component failed validation. There were errors during task validation.
Maybe the source of the problem is that this machine is a 64-bit one, while the developer machine is 32-bit one. But why does the package run fine when I start it from Management Studio?
Can some one here give me more insight about how to upgrade a SQL Server 2005 Standard Version (32 bits) to a SQL Server 2005 Enterprise Version (32 bits) as default instance on a Windows 2003 enterprise OS (32 bits). I want to know what is the easist way and what is the safest way. May I preserve some settings I have for the STD version, or I have to start from strach again to configure the server? Is there any catches, anything I should have attention to (We are using heavily about CLR and fulltext indexing)?
Hello, I installed the SQL Server 2k EnterPrise version and developer version on the same version, and the developer version is an instance "Development". How do I expose both of them to internet? Just open both of them to port 1433? And on the client side, just say IP and IP/Development? Do I need specific set up, will they conflict? Thanks,
The version of the report server database is either in a format that is not valid, or it cannot be read. The found version is 'C.0.8.54'. the expected version is 'C.0.8.40'. To continue, update the version of the report server database and verify access rights. I'm getting this whenever try to access the report server via SSMS, I have tried to upgrade via the Reporting Service Configuration Manager but get an error message similar to above except it says: The database version (C.o.8.54) does not match your Reporting Services installation. This version of the database cannot be upgraded. You must use a different database. Has anyone seen this before? I can create a new database, but don't want to loose all my reports. Any ideas. Oh, not even sure if the backups exist from before this error, I've spent 2 weeks trying to get access to the server so I could try to upgrade, only to get the above results. Thanks for your help, David
I downloaded the 101 Samples installation (i.e. 101SamplesCS.msi) from Microsoft's website, which contains SQL Server database files.
While working with the databases in the "Data Access" samples from the 101 Samples projects, I get the following error:
"Database <mdf_name> cannot be upgraded because its non-release version (600) is not supported by this version of SQL Server. You cannot open a database that is incompatible with this version of sqlservr.exe. You must re-create the database..."
I assume the database files were created with a beta or CTP version of SQL Server 2005. Does anyone know where I can get an updated version of these database files or scripts to update them?
Can I set up sql server 7.0 standard version in cluster enviorment, what the different betwent sql server 7.0 enterprise version and standard version? any problem I may encouter when I install the SQL server 7.0 standard version in Cluster enviorment? Thank you very much. Judy
We have a Sqlserver 2005 Installed on One of our servers.I wanted to know whether the installed database is a Evaluation copy or Licensed Copy.How to Evaluate this. Do we have to check any Log files etc for knowing whether it is evaluation copy or Licensed copy. Please help me Asap. thanks in Advance
Hello,I have a table that has a name field with the following datajohn doejohn doe smithjohn d smithI need to separate the first, middle and last names into separatefields. ex. first varchar (20), middle varchar (20) and last varchar(20).I am testing the process that I have to follow by doing the followingcreate table names (name varchar (40),first varchar (20),middle varchar (20),last varchar (20))insert into names (name)values (john doe smith)I get an error message when I run the following query:update bset first = substring(name, 1, (charindex('', name)-1))The error message is:Server: Msg 536, Level 16, State 3, Line 1Invalid length parameter passed to the substring function.The statement has been terminated.Does anybody have any suggestions?TIAja
I am fairly new to SQL and am trying to write a function to parse the ip address into 4 sections. I have been searching through the forums to see if anyone has a posted example of parsing an ip address but could not find one.
I am wondering what would be the best method of doing this, or if anyone has an example.
I have a table, tblstudents that has the fields strfirstname and strlastname. The table was imported from MS Acess where they were storing the first name and the lastname in the same field. Sucks doesn't it? Anyway, I need to write a script to extract the first name from the lastname and insert it into the first name field which is blank. So far I figure I can use select into, but need to find a way to tell sql server to take the fart of the field after the comma (the first name) and to delete the comma becuase I won't need it anymore.
Help!
Select '%,' into tblclients as strfirstname from tblclients
I know this won't work, but I want to show you all I'm at least trying!
Hi there,I am re-organizing the database. We used to have field 'names' in ourtable for our first name and last name. However, I want to have thosenames in different field.FYI, I have two different tables in different databases. The Adatabase contains A table with 'names" field. The B database containsB table with 'fname' and 'lname' I want to copy data A table to Btable.How can I parse names field into first name and last name fields?Here are some examples which are in the database.(id names01 John Doe02 John & Jane Doe03 Mr & Mrs Doe) something like this. It might contain '&' and two names. If thereare two names, then use first name.Thanks guys,
In my stored procedure, I want to parse @ArrayOfDays into @d1 through@d5.@ArrayOfDays is a varchar input parameter containing,for example, "1.7.21.25.60." - five elements.Most active vars:@i - loop counter@char - current char in string@tempVal - contains the current element as it is being built@tempValExecString - contains SELECT stmt for EXEC()I'm using EXEC() to execute a dynamically built SELECT.The error I get when calling from vb.net is:Must declare the variable '@tempVal'.Two manual traces indicate the logic is ok.I suspect my assignment statement for @tempValExecString.Any help would be appreciated. - BobC----------------------------------------------------------DECLARE@d1 varchar(3),@d2 varchar(3),@d3 varchar(3),@d4 varchar(3),@d5 varchar(3),@i int,@char char(1),@tempVal varchar(3),@tempValExecString varchar(30)SELECT @tempVal = ''SELECT @i = 1WHILE @i < LEN(@ArrayOfDays)BEGINSELECT @char = SUBSTRING(@ArrayOfDays, @i, 1)WHILE @char <'.'BEGINSELECT @tempVal = @tempVal + @charSELECT @char = SUBSTRING(@ArrayOfDays, @i+1, 1)IF @char = '.'BEGIN/* the following should produce "SELECT @d1 = 1" when it reads thefirst period(.) */SELECT @tempValExecString = 'SELECT @d' + LTRIM(RTRIM(STR(@i))) + '= @tempVal'EXEC(@tempValExecString)SELECT @tempVal = ''SELECT @i = @i + 1ENDSELECT @i = @i + 1ENDEND----------------------------------------------------------
Is there a way to parse a string to int? this is my example code. quote_id is a string i want to be treated as an int here.
Code Snippet ALTER PROCEDURE [dbo].[GetNextQuoteID] AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT MAX(quote_id)+1 as id From Quote END
Does anyone come across this error message whenever u try to parse ANY SQL statements in Management Studio 2005 (even parsing SELECT GETDATE() fails)...
>>>
.Net SqlClient Data Provider: Msg 0, Level 11, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded. >>>
Actually, i need to trace out changes in my database.[either by insertion/updation/deletion of data or adding/modifiying object.] within my application.
I study SQL Profile. But it is limited for its run and also resource hunger or extra burden on server in case of large size database and busy server.
So please guide me. Also suggest be its appropriate solution.
i am executing an sql statement in sql server 2005 express edition. It says it is unable to parse the query then automatically re-arranges the sql text and then it is able to parse it and return me the result. my query is this: What am I doing wrong? IF NOT EXISTS (SELECT MemberID, HotelID FROM tblHotels_Reviews WHERE MemberID = 3 AND HotelID = 3) BEGIN INSERT INTO tblHotels_Reviews(MemberID, HotelID, ReviewTitle, StayMonth, StayYear, Satisfaction, PricePerNight, ValueForMoney, CheckIn, FoodDining, BusinessFacilities, SafetySecurity, Rooms, StaffService, HotelFacilities, CheckOut, SuitableFor, Atmosphere, DoYouRecommend, Review, Anonymous, HasPhotos, ReviewDate, ReviewLanguage, PublishStatus)VALUES (6, 3, 'hello', 'January', 2002, 5, 234, 5, 5, 5, 5, 5, 5, 5, 5, 5, 'Singles,Couples', 0, 1, 'helloo', 0, 0, '06/04/2006', 'EN', 0) SELECT 1 AS RESULT END ELSE BEGIN SELECT 0 AS RESULT END
I create a Execute SQL Task and Load a stored procedure into the "SQL Statement" box. This stored procedure has many 'go' words and many commented lines either with '--' mark or '/*' or '*/' mark.
When Parse Query, get Package Error "Deferred prepare could not be completed. Statements could not be prepared". But I could run the same proc under the isql/w with no problem. How could I deal with this error? Though it looks the execution of the package still run successful. The Parsing just create uncertainty.