Mondial SQL Database Questions and Answers

You can find the Mondial SQL database here List all the countries that are part of Nato SELECT distinct c.name FROM Mondial.country c left join Mondial.isMember m on c.code = m.country where m.organization like ‘%nato%’; List all countries that are part of and organisation that was founded before 1960 SELECT * FROM Mondial.country c left join Mondial.isMember m on c.code …

SQL: Bulkinsert data FROM CSV or TXT File

Very useful for bulk inserting data rapidly from multiple files. At the moment with this sequence you will need to change the file manually. Still very useful. Make sure you check that no columns were imported accidentally.   BULK INSERT [Clientdatabase].[dbo].[journalentries] FROM ‘C:\Users\mxk\Desktop\Clientfolder\Rawdata\Clientdata.TXT’ WITH ( fieldterminator = ‘~’, rowterminator = ‘\n’, firstrow = 2, tablock )

SQL Error: Argument data type date is invalid for argument 2 of dateadd function

You new to cast the complete column as an integer before you can use the dateadd function. That means the following code: ,dateadd(d, CONVERT(date, CASE WHEN fda.[Column1] != 0 THEN fda.[Column1] WHEN fda.[Column2] != 0 THEN bfda.[Column1] ELSE fda.[Column3] END ,114), CONVERT(date, fda.[Column3], 114)) AS [tdate] needs to be changed to the code below. Note the convert becomes cast.   …