How to Find and Replace Values in All Tables and All Text Columns in SQL Server
Problem 1:
We have a tables (SQL Server) which references paths (with specific name/ value), but now the path is going to change. In the path column, we have many records and we need to change just a portion (name/ value) of the path, but not the entire path. And we need to change the same string to the new one, in every record.
How can we do this with a simple update?
Problem 2:
We have read about a SQL injection attack where text is inserted and this could be a good way to remove the offending text.
Magic of Sql Server with Update query
Magic of SQL Server
Today we will talk about magic of Sql Server. There is a scenario, we need to swap value between two columns, what will be sql query for that?
Look the following sql query and you will surprised that there is a simple way to do that in Sql without using third variable.
update tablename
set firstName=lastName,lastName=firstName
Tell me above sql query will be execute or we will get error.
How can we get last Identity value in SQL Server
When we insert data in table in SQL, in that case we need to get the reference of new inserted row, how can we do that?
There are some internal functionality in SQL Server through which we can get that value from SQL Server.
1.) @@IDENTITY
2.) SCOPE_IDENTIT
3.) IDENT_CURRENT