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

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.