CREATE OR ALTER PROCEDURE - sql-server

According to this blog, CREATE OR ALTER feature was introduced in SQL Server 2016 SP1 but when I executed this statement for my SQL Server 2008 R2 version database, it worked. Any idea why?

Related

Is it safe to do forward restore in SQL Server?

I have restored a .bak file from my SQL Server 2008 R2 to my 2017 instance (both Developer editions) and it seems to work fine.
Does it really restore all the user defined objects? And are all those objects work same as the way they work in 2008 R2 instance?
Yes, SQL Server 2017 has a forward compatibility with backups created in SQL Server 2008R2.
The restore process restores all user and system objects and then perform an upgrade of them to a current version.
Important: the database will still be in an old compatibility level - 100, which corresponds to SQL Server 2008R2. In order to get all new optimizations and features available, consider to change your database to the latest compatibility level. For SQL Server 2017 it is: 140.
ALTER DATABASE [DbName] SET COMPATIBILITY_LEVEL = 140;
This will also enable query optimizer and t-sql enhancements which were introduced since 2008R2.
And then update statistics
USE [DbName]
EXEC SP_UPDATESTATS
Worth to mention that compatibility change is a backward reversal, while backup created in SQL Server 2017 cannot be restored in 2008R2.
yes, they will work fine in 2008 R2 Instance.

Parse SQL script as 2005 in 2012?

In SQL Server 2012 Management Studio, is there a way to to parse my SQL as SQL Server 2005 syntax? My development PC has SQL Server 2012 Express but the production server uses 2005. I have to hook into a 2005 development server to run my tests before pushing to production.
It would be really nice if I could test for SQL Server 2005 correctness from a 2012 server
use Compatibility Level.
For 2005, use COMPATIBILITY_LEVEL 90
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = 90
refer to here for more information
https://msdn.microsoft.com/en-us/library/bb510680.aspx

Can we restore SQL Server 2008R2 backup on SQL Server 2014?

Currently, one of our product running on the SQL Server 2008R2.
For new installation client want to go for SQL Serer 2014 because at this location Microsoft is not selling licence for the SQL Server 2008R2.
In SQL Server 2014, you can restore a user database from a database backup that was created by using SQL Server 2005 or a later version. However, backups of master, model and msdb that were created by using SQL Server 2005 through SQL Server 2012 cannot be restored by SQL Server 2014. Also, backups created in SQL Server 2014 cannot be restored by any earlier version of SQL Server.
Source
Yes.
Wen you restore database backup that created with older version of SQL Server in to new version, SQL Server automatically updated your database in new version. But don't change compatibility level of your database. You can change Compatibility level of your database after restore complete by following query :
ALTER DATABASE test SET COMPATIBILITY_LEVEL = 120
In SQL Server 2014 SP1 there are breaking changes to the restoreheader definition (3 new fields added).
If you use it, you should have a look at this thread:
breaking changes to SQL Server 2014 SP1 - restoreheader

insert hebrew string to database with SQL Server 2008 R2

I am trying to insert hebrew strings into a SQL Server database using visual studio 2010 and SQL Server 2008 R2 with connection string but in the database table I get ????? instead of the original string. Just to mentions that it doesn't happen in the past. What could be the problem?
You have to change database collation.
Run the following script :
USE master;
GO
ALTER DATABASE YOUR_DATABASE_NAME
COLLATE Hebrew_CI_AS ;
GO

Convert SQL Server 2008 database to SQL Server 2005

Convert SQL Server 2008 database to SQL Server 2005. Any solution please?
You can script your 2008 database to create the database objects and insert data, then run that script on the 2005 instance. You might have to temporarily disable foreign keys to get some of the inserts to work.
If you want to set the compatibility level of your 2008 SQL Servers to be 2005 (so that you are effectively saying that they are all 2005), you can use the SET COMPATIBILITY_LEVEL command to do this...MSDN link
Using there example, you would run this on your 2008 databases:
ALTER DATABASE database_name -- change me!
SET COMPATIBILITY_LEVEL = 90 -- set to sql server 2005 compatibility level

Resources