Useful command of MSSQL Query when comparing and manipulating text data

Extract table from another table

SELECT *
FROM dbo.SFG_Event_21_22
except
SELECT *
FROM dbo.SFG_Event_21

Bulk insert

BULK insert dbo.SFG_Event_21_22
from ‘C:\Users\joemac\Desktop\final.csv’
WITH
(
firstrow = 1,
fieldterminator = ‘,’,
rowterminator = ‘0x0a’
);
GO

  • bulk insert cannot understand text qualifier
  • bulk insert add NULL for blank data by default

Replace string value of a column

UPDATE dbo.SFG_Event_ResultFromApp
SET [17] = REPLACE([17], ‘;’, ‘,’)

 

 

 

Leave a comment

Your email address will not be published.