Posts

MSSQL - Date Format

Web Reference : www.sql-server-helper.com Standard Date Formats Date Format SQL Statement Sample Output Mon DD YYYY 1 HH:MIAM (or PM) SELECT CONVERT(VARCHAR(20), GETDATE(), 100) Jan 1 2005 1:29PM 1 MM/DD/YY SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] 11/23/98 MM/DD/YYYY SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] 11/23/1998 YY.MM.DD SELECT CONVERT(VARCHAR(8), GETDATE(), 2) AS [YY.MM.DD] 72.01.01 YYYY.MM.DD SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD] 1972.01.01 ...

MSSQL - DATEADD Function

Syntax: DATEADD (datepart , number , date ) Datepart Abbreviations year yy, yyyy quarter qq, q month mm, m dayofyear dy, y day dd, d week wk, ww weekday dw, w hour hh mi...

MSSQL - LEFT OUTER JOIN

Example: Left Outer Join SELECT Customers.CustomerName, Sales.SaleDate FROM Customers LEFT OUTER JOIN Sales ON Sales.CustID = Customers.CustID

MSSQL - Alter Column Data Type

In normally in SQL, syntax for alter table is ALTER TABLE table_name MODIFY column_name data_type Example. ALTER TABLE products MODIFY product_name VARCHAR2(50) But if in MSSQL, you have to use "ALTER COLUMN" instead. ALTER TABLE table_name ALTER COLUMN column_name data_type Example. ALTER TABLE products ALTER COLUMN product_name varchar(50)

C# - AES Encrypt

input: string message, string keycode output: string BASE64String using System.Security.Cryptography; RijndaelManaged aesCipher = new RijndaelManaged(); ASCIIEncoding textConverter = new ASCIIEncoding(); Byte[] iv; aesCipher.KeySize = 128; aesCipher.BlockSize = 128; aesCipher.Mode = CipherMode.ECB; aesCipher.Padding = PaddingMode.Zeros; aesCipher.Key = textConverter.GetBytes(keycode); ICryptoTransform crypto = aesCipher.CreateEncryptor(); Byte[] toEncrypt = textConverter.GetBytes(messg); Byte[] cipherText = crypto.TransformFinalBlock(toEncrypt, 0, toEncrypt.Length); String base64Str = ""; base64Str = Convert.ToBase64String(cipherText);

C# - Server Variable

Example: String _user_agent = Request.ServerVariables["HTTP_USER_AGENT"]; String _all_http = Request.ServerVariables["ALL_HTTP"]; Response.Write("user_agent:" + _user_agent + ","); Response.Write("ALL HTTP:" + _all_http); All Server Variable: ALL_HTTP ALL_RAW APPL_MD_PATH APPL_PHYSICAL_PATH AUTH_PASSWORD AUTH_TYPE AUTH_USER CERT_COOKIE CERT_FLAGS CERT_ISSUER CERT_KEYSIZE CERT_SECRETKEYSIZE CERT_SERIALNUMBER CERT_SERVER_ISSUER CERT_SERVER_SUBJECT CERT_SUBJECT CONTENT_LENGTH CONTENT_TYPE GATEWAY_INTERFACE HTTPS HTTPS_KEYSIZE HTTPS_SECRETKEYSIZE HTTPS_SERVER_ISSUER HTTPS_SERVER_SUBJECT INSTANCE_ID INSTANCE_META_PATH LOCAL_ADDR LOGON_USER PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_USER REQUEST_METHOD SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_PORT_SECURE SERVER_PROTOCOL SERVER_SOFTWARE URL HTTP_CACHE_CONTROL HTTP_CONNECTION HTTP_ACCEPT HTTP_ACCEPT_ENCODING HT...

MSSQL - How to set Case Sensitive in varchar data type

The default setting of the varchar data type in MSSQL2008 is non-case sensitive. The lower-case is equal the upper-case ex. cat = CaT. If you need the difference between upper-case and lower-case on your data, you can set your field by: 1. Right click on your table and select "Design". 2. Click on your field you need to set " Case-Sensitive " and see at "Column Properties" window below. 3. In "Column Properties" window, find "Table Designer" and click on the right column of "collation" 4. In the pop up window. Choose "windows Collation" -> Dictionary Sort and check on Case Sensitive 5. Click "OK" to finish.