UPDATE and REPLACE part of a string

I’ve got a table with two columns, ID and Value. I want to change a part of some strings in the second column. Example of Table: ID Value ——————————— 1 c:\temp\123\abc\111 2 c:\temp\123\abc\222 3 c:\temp\123\abc\333 4 c:\temp\123\abc\444 Now the 123\ in the Value string is not needed. I tried UPDATE and REPLACE: UPDATE dbo.xxx SET … Read more

Rename column SQL Server 2008

I am using SQL Server 2008 and Navicat. I need to rename a column in a table using SQL. ALTER TABLE table_name RENAME COLUMN old_name to new_name; This statement doesn’t work. 1Best Answer 11 Use sp_rename EXEC sp_RENAME ‘TableName.OldColumnName’ , ‘NewColumnName’, ‘COLUMN’ See: SQL SERVER – How to Rename a Column Name or Table Name … Read more

Reset identity seed after deleting records in SQL Server

I have inserted records into a SQL Server database table. The table had a primary key defined and the auto increment identity seed is set to “Yes”. This is done primarily because in SQL Azure, each table has to have a primary key and identity defined. But since I have to delete some records from … Read more

Sql Server ‘Saving changes is not permitted’ error ► Prevent saving changes that require table re-creation

When I create a table in SQL Server and save it, if I try to edit the table design, like change a column type from int to real, I get this error: Saving changes is not permitted. The change you have made requires the following table to be dropped and re-created. You have either made … Read more

How can I delete using INNER JOIN with SQL Server?

I want to delete using INNER JOIN in SQL Server 2008. But I get this error: Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword ‘INNER’. My code: DELETE FROM WorkRecord2 INNER JOIN Employee ON EmployeeRun=EmployeeNo WHERE Company = ‘1’ AND Date=”2013-05-06″ 1 16 You need to specify what table you … Read more

How to check if a column exists in a SQL Server table?

I need to add a specific column if it does not exist. I have something like the following, but it always returns false: IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ‘myTableName’ AND COLUMN_NAME = ‘myColumnName’) How can I check if a column exists in a table of the SQL Server database? 3 32