Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imrexhuang/3715d6087e26f77577a1b5df937bb38b to your computer and use it in GitHub Desktop.
Save imrexhuang/3715d6087e26f77577a1b5df937bb38b to your computer and use it in GitHub Desktop.
--TSQL利用CASE WHEN處理欄位的NULL值
SELECT 'new CustomersEntity("'+ [CustomerID] + '" , "' + [CompanyName] + '" , "' + [ContactName] + '" , "' + [ContactTitle] + '" , " ' + [Address] + '" , "' + [City] + '" , "'
+ CASE WHEN [Region] IS NULL THEN '' ELSE [Region] END + '" , "'
+ CASE WHEN [PostalCode] IS NULL THEN '' ELSE [PostalCode] END + '" , "'
+ [Country] + '" , "' + [Phone] + '" , "'
+ CASE WHEN [Fax] IS NULL THEN ' ' ELSE [Fax] END + '" ' --SQL結尾
+');'
FROM [dbo].[Customers]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment