Showing posts with label SQL Server 2008 R2. Show all posts
Showing posts with label SQL Server 2008 R2. Show all posts

Thursday, October 29, 2015

SQL Server: Save changes is not permitted. Resolution

Save changes is not permitted. The changes you have made require the following tables to be dropped and recreated. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

User canceled out of save dialog.

Solution:

  • Go to Tools > Options

  • Go to Designers > Table and Database Designers
  • Uncheck the Prevent saving changes that require the table recreation.

Thursday, January 1, 2015

Update SQL Table with joins

Following is the query to update sql table with joins

UPDATE a
SET a.sortorder = b.sort_order
FROM picture AS a
INNER JOIN (select row_number() over (order by id) as sort_order,id,projectid from picture
where projectid = 61
) AS b
       ON a.id = b.id
where a.projectid = 61


select * from picture order by id desc


SQL REPLACE() : Argument data type ntext is invalid for argument 1 of replace function.

SQL Server Replace function does not work with text and ntext data types.
Following query contains replace function for ntext type column.

update description_table set description = replace(description,'../G/','http://styletint.in/G/') where description like '%../G/%'

this query is will return following error:

Argument data type ntext is invalid for argument 1 of replace function.

To resolve this, we can cast ntext type to nvarchar(max) and then update column with this value: Following query will work without any error:

update description_table set description = replace(CAST(description AS NVARCHAR(MAX)),'../G/','http://styletint.in/G/') where description like '%../G/%'


Wednesday, December 24, 2014

SQL Server 2008 R2 can't connect to local database in Management Studio (Cannot connect to local instance)


Make sure that you are connecting via correct instance name. If your instance is SQLEXPRESS, then you need to use .\SQLEXPRESS or machie-host-name\SQLEXPRESS  as your server name.
And if you have a named instance then put that name as server name.

If this does not solve your problem then you need to check in services if your service is running or not.
Go to Run
 Type services.msc

Go to SQL Server (MSSQLSERVER) service.
Right click service and START

This should resolve your issue.

Write me if you are still facing same issue.