Advertisement
Guest User

SQL 08-12-18

a guest
Dec 8th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.71 KB | None | 0 0
  1. declare @myTinyInt as TINYINT = 25;
  2. declare @myInt as INT = 666;
  3. select @myTinyInt + @myInt;
  4.  
  5. declare @myChar as CHAR(6) = 'six';
  6. declare @myInt as INT = 1;
  7. select @myChar + @myInt;
  8.  
  9. select empid, lastname
  10. from HR.Employees
  11. where lastname COLLATE Latin1_General_CS_AS = N'Funk'
  12.  
  13. select empid, lastname, firstname + N' ' + lastname as fullname
  14. from HR.Employees
  15.  
  16. select empid, lastname, CONCAT(firstname, N' ', lastname) as fullname
  17. from HR.Employees
  18.  
  19. SELECT TOP(3) orderid, FORMAT(orderdate, 'd', 'en-us') as us,
  20. FORMAT(orderdate, 'd', 'de-DE') as de
  21. FROM Sales.Orders;
  22.  
  23. SELECT SUBSTRING('Microsoft SQL Server', 11, 3);
  24.  
  25. SELECT LEFT('Microsoft SQL Server', 9);
  26.  
  27. SELECT LEN('Microsoft SQL Server    ');
  28. SELECT DATALENGTH('Microsoft SQL Server     ');
  29.  
  30. SELECT CHARINDEX('SQL', 'Microsoft SQL Server');
  31.  
  32. SELECT REPLACE('Microsoft DUPA Server', 'DUPA', 'SQL');
  33.  
  34. SELECT UPPER('Microsoft SQL Server');
  35. SELECT LOWER('Microsoft SQL Server');
  36.  
  37. SELECT orderdate, orderid
  38. FROM Sales.Orders
  39. WHERE orderdate = '20070825'
  40.  
  41. declare @DateOnly as DATETIME ='20120225'
  42. SELECT @DateOnly;
  43.  
  44. SELECT GETDATE(),
  45. CURRENT_TIMESTAMP,
  46. GETUTCDATE(),
  47. SYSDATETIME(),
  48. SYSUTCDATETIME(),
  49. SYSDATETIMEOFFSET();
  50.  
  51. SELECT datename(year, '20120220')
  52. SELECT month('20120220')
  53.  
  54. SELECT datediff(millisecond, GETDATE(), SYSDATETIME());
  55.  
  56. SELECT DATEFROMPARTS(2012, 12, 31);
  57. SELECT DATETIMEFROMPARTS(2012, 12, 31, 8, 30, 0, 0);
  58. SELECT DATETIME2FROMPARTS(2012, 12, 31, 8, 30, 0, 0, 0);
  59.  
  60. SELECT DATETIMEOFFSETFROMPARTS(2012, 12, 31, 8, 30, 0, 0, -7, 0, 0)
  61.  
  62. SELECT ISDATE('20180202');
  63.  
  64. SELECT ISDATE('20180231');
  65.  
  66. SELECT CAST(1 as VARCHAR(10)) + 'abc';
  67.  
  68. SELECT CAST('20120305' as  date)
  69.  
  70. SELECT CONVERT(DATE, '12/11/2018', 101);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement