<< < 1 2 3 4 5 6 7 8 > >>   Sort: Date

CONVERT() - Converting Numeric Expression Data Types in SQL Server
How To Convert Numeric Expression Data Types using the CONVERT() Function in SQL Server Transact-SQL? If you want to convert the data type of a numeric expression to a new data type, you can use the CONVERT(data_type, expression) function. The tutorial exercise below shows you how to use the CONVERT...
2017-03-27, 285👍, 0💬

ROUND() - Rounding Values to Specific Precisions in SQL Server
How To Round a Numeric Value To a Specific Precision in SQL Server Transact-SQL? Sometimes you need to round a numeric value to a specific precision. For example, you may want to round values in your financial statement to the precision of 1000.00. This can be done by the ROUND() function with the f...
2017-03-11, 284👍, 0💬

"@@FETCH_STATUS" - Looping through Result Set in SQL Server
How To Loop through the Result Set with @@FETCH_STATUS in SQL Server Transact-SQL? The FETCH statement only returns one row from the result set. If you want to return all rows, you need to put the FETCH statement in a loop. A simple way to stop the loop to check the system variable @@FETCH_STATUS, w...
2016-10-17, 284👍, 0💬

AND, OR, XOR, and NOT - Bitwise Operations in SQL Server
What Are Bitwise Operations in SQL Server Transact-SQL? Bitwise operations are binary operations performed on one or two binary strings. SQL Server supports 4 bitwise operations: & (Bitwise AND) - Performing the single bit Boolean operation "AND" on each bit position. | (Bitwise OR) - Performing...
2017-02-25, 282👍, 0💬

CHARINDEX() and SUBSTRING() - Locating and Taking Substrings in SQL Server
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-SQL? Transact-SQL is not a language designed for manipulating strings, but it does have two simple functions to locate and take substrings: CHARINDEX() and SUBSTRING(). The tutorial exercise below ass...
2017-03-07, 280👍, 0💬

sys.procedures - Listing All Stored Procedures in SQL Server
How To List All Stored Procedures in the Current Database in SQL Server Transact-SQL? If you want to see a list of stored procedures in your current database, you can use the system view, sys.procedures as shown in this tutorial exercise: USE FyiCenterData; GO SELECT * FROM sys.procedures; GO Name o...
2017-01-05, 280👍, 0💬

sys.sql_modules - Getting Stored Procedure Definitions Back in SQL Server
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the definition of an existing stored procedure back from the SQL Server, you can use the system view called sys.sql_modules, which stores definitions of views and stored procedures. The sys.sql_modules h...
2017-01-05, 280👍, 0💬

NULLIF() - Replacing Given Values with NULL in SQL Server
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want to hide certain values by replacing them with NULL values. SQL Server offers you a nice function called NULLIF() to do this: NULLIF(expression, value) -- Returns NULL if "expression" equals to value" -...
2017-01-29, 279👍, 0💬

Formatting Time Zone in +/-hh:mm Format in SQL Server
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, you know how to calculate the time zone value by using GETDATE() and GETUTCDATE() functions. But how can you format that time zone value in a nice looking format like +05:45 or -04:00? Unfortunately, S...
2017-02-08, 278👍, 0💬

ISNULL() - Replacing NULL Values in Expressions in SQL Server
How To Replace NULL Values in Expressions using ISNULL() in SQL Server Transact-SQL? As you learned from previous tutorials, NULL values presented in expressions will cause the final results to be NULL. Sometimes, you want NULL values to be replaced with some default values, like 0, '', or 'NULL', s...
2017-02-03, 277👍, 0💬

Verify Time Precision in SQL Server Transact-SQL
How to verify the precession of the server system time in SQL Server Transact-SQL? You can run a WHILE loop to check the precision of server system time in Transact-SQL as shown below: DECLARE @var DATETIME2(7); DECLARE @count INT = 0; WHILE @count<100 BEGIN SET @count = @count + 1; SET @var = SY...
2017-02-22, 274👍, 0💬

Converting Binary Strings into Integers in SQL Server
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers are convertible implicitly and explicitly. But there several rules you need to remember: Binary strings will be implicitly converted into an integer data type, if it is involved in an arithmetical ope...
2017-02-28, 273👍, 0💬

Adding and Removing Days on Date and Time Values in SQL Server
How To Add or Remove Days on Date and Time Values in SQL Server Transact-SQL? SQL Server 2005 only support two operators on data and time values: + (Add): Adding days to a date and time value. - (Subtract): Removing days from a date and time value. Note that to add or subtract days on a date and tim...
2017-02-22, 272👍, 0💬

Performing Comparison on Date and Time Values in SQL Server
How To Perform Comparison on Date and Time Values in SQL Server Transact-SQL? Comparison operations on date and time values can be performed in the same way as numeric values. The comparison rule is simple: a date and time value in the future has a greater value than a date and time value in the pas...
2017-01-21, 272👍, 0💬

Load Data through External Tables in Oracle
How To Load Data through External Tables in Oracle? If you have data stored in external files, you can load it to database through an external table by the steps below: Create an external table with columns matching data fields in the external file. Create a regular table with the same columns. Run ...
2016-11-27, 272👍, 0💬

Converting DATETIME and NUMERIC Values in SQL Server
Are DATETIME and NUMERIC Values Convertible in SQL Server Transact-SQL? Are datetime and numeric value convertible? The answer is yes. Here are the main rules on DATATIME and NUMERIC value conversions: During the conversion a DATETIME value will be treated as a NUMERIC value with the number of days ...
2017-02-22, 271👍, 0💬

Performing Comparison on Exact Numbers in SQL Server
How To Perform Comparison on Exact Numbers in SQL Server Transact-SQL? Comparison operations on exact numbers of data types: BIT, INT, NUMERIC, etc., are very easy to understand. Here are some simple examples: -- BIT value comparison DECLARE @x BIT, @y BIT; SET @x = 0; SET @y = 1; SELECT CASE WHEN @...
2017-01-21, 270👍, 0💬

Get System Date and Time in SQL Server Transact-SQL
How to get system date and time in SQL Server Transact-SQL? I want a list of functions for getting current system date and time. Here is a comparison of all functions that you can use to get the current date and time from the data base server system: Function Return type Precision ------------------...
2017-02-25, 269👍, 0💬

Converting Unicode Strings to Non-Unicode Strings in SQL Server
How To Convert a Unicode Strings to Non-Unicode Strings in SQL Server Transact-SQL? Since Unicode character set is different than code page based (non-Unicode) character set, converting Unicode strings to non-Unicode strings may result in wrong characters or missing characters. So you should avoid c...
2017-03-07, 268👍, 0💬

Inserting New Line Characters into Strings in SQL Server
How To Insert New Line Characters into Strings in SQL Server Transact-SQL? If you want to break a string into multiple lines, you need to insert new line characters into the string. With some client tools like SQL Server Management Studio, it is not so easy to insert a new line character. One work a...
2017-03-07, 268👍, 0💬

bin2hex - Converting Binary Strings into Hexadecimal Character Strings in SQL Server
How To Convert Binary Strings into Hexadecimal Character Strings in SQL Server? When a query returns a binary string value to the client tool, it will be displayed by the client tool as hexadecimal digits in a character string format. But they are hexadecimal digits on the display window, not in the...
2017-02-25, 268👍, 0💬

Sorting Query Output by Multiple Columns in SQL Server
Can the Query Output Be Sorted by Multiple Columns in SQL Server? You can specifying multiple columns in the ORDER BY clause as shown in the following example statement, which returns rows sorted by "tag" and "counts" values: SELECT tag, counts, url, created FROM fyi_links ORDER BY tag, counts GO ta...
2016-10-26, 268👍, 0💬

SET Statements in SQL Server Transact-SQL
How to assign value to a variable in SQL Server Transact-SQL? How to use the SET statements? In Transact-SQL, you can use SET statements to assign values to variables using the assignment operator =, in the syntax of: SET @variable = <value> When an SET statement is executed, the system will: ...
2017-04-04, 267👍, 0💬

CONVERT() - Formatting DATETIME Values to Strings in SQL Server
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL Server 2005 offers no functions to format DATETIME values in your own format patterns. But it does provide you a number of pre-defined format patterns that you can use with the CONVERT(char_type, dat...
2017-02-08, 267👍, 0💬

<< < 1 2 3 4 5 6 7 8 > >>   Sort: Date