Get data out of a table.
SELECT TOP (1000) [Id] ,[Name] FROM [dbo].[Hello]
Insert new data to an existing table
INSERT INTO Users (username, mail)
VALUES ('username', 'mail');
Delete stuff from a table
DELETE FROM table_name WHERE condition;
Update stuff within a table
UPDATE Cities SET Location.X = 23.5 WHERE Name = 'Anchorage';
for spatial data in SQL Server
INSERT INTO "MyCoordinates" ("Geometry") VALUES ('POLYGON((0 0, 100 0, 100 100, 0 100, 0 0))',);
REPLACE function in a SQL update statement. Here’s an example SQL script:UPDATE my_table SET my_column = REPLACE(my_column, 'old_string', 'new_string') WHERE my_column LIKE '%old_string%';
my_table with the name of the table you want to update, and my_column with the name of the column containing the string you want to replace. You would also replace 'old_string' with the string you want to replace, and 'new_string' with the new string you want to use.WHERE clause limits the update to only those rows that contain the old string, to avoid changing any data that doesn’t need to be updated.UPDATE statement for each column.
select
object_name(object_id) as OBJ_NAME, *
from
sys.dm_db_index_usage_stats
where
database_id = db_id(db_name())
Order by
dm_db_index_usage_stats.last_user_update desc
SELECT name [Table],
Create_date [CreateDate],
modify_date [LastUpdate]
FROM sys.all_objects
WHERE type = 'U'
ORDER BY modify_date DESC;
UPDATE Maps SET Uri = REPLACE(Uri, 'uri1', 'uri2')
CREATE LOGIN yourusername WITH password='yourpw';
CREATE USER [yourusername] FROM LOGIN yourusername;
ALTER ROLE [db_datareader] ADD MEMBER [yourusername];
USE master; ALTER DATABASE MyTestDatabase MODIFY NAME = MyTestDatabaseCopy;