|
|
-
|
|
There was a question in the SQL forums that the user wanted to remove leading zeroes in the numbers from a varchar column. The column will have numbers, alphabets or alpha-numeric strings. Only numbers should be considered for removing the leading zeroe...
|
|
-
|
|
Finding distinct values is often needed in such cases like finding distinct items that were sold last month, etc. You can very well use DISTINCT keyword to do this. However there are some other ways too to find distinct values
Consider the following set...
|
|
-
|
|
Consider the following set of data and queriesdeclare @t table(item_id int identity(1,1),item varchar(10))
insert into @t(item)
select 'TV' union all
select 'Computer' union all
select 'Laptop' union all
select 'VCD' union all
select 'CD'
--Query 1
de...
|
|
-
|
|
There was a question in the forums where a user asked for a solution to find out the number which is succeeded by the last 0 in that number
For example, in numbers like 10807023 and 1000508, 23 and 8 are the numbers which are succeeded by the last 0 of...
|
|
-
|
|
I see developers often confused on how they get the list of objects by IntelliSense when writing the code. Here are some points on how you can intelligently make use of IntelliSense.
When IntelliSense is enabled, in the query window, type SELECT and a s...
|
|
-
|
|
Arithmetic operators are used to perform arithmetic operations like addition, subtraction, multiplication and division. However the operators + ,- and ~ can also be used as unary operators to decide if a number is positive or negative. But we can have f...
|
|
-
|
|
Run the following code
select ' ' ' ' -- Query 1
select '''' -- Query 2
How does the first query return single space whereas the second query returns single single quote?...
|
|
-
|
|
The batch separator in SQL Server signals the end of the batch. By default SQL Server uses GO as the batch separator. However often people get confused on when they should use it compulsorily. Here are the cases where you must use batch separator
1 A...
|
|
-
|
|
I had a requirement to convert table data in XML format. The format is expected to be
. . .
Create this testing table create table testing
(
id int,
first_nam...
|
|
-
|
|
Often, you are advised not to use * in your SELECT statement. It is because the code that depends on * may be broken if a column is added or removed. If you have a view that uses *, it will not reflect newly added/removed column until the view is ...
|
|