S.No | ComboBox | ListBox | |
1 | Select | One Data | Multiple Data. |
2 | Facility | Drop Down Facility. | Drop up and Drop Down Facility |
3 | check Box | can't Use CheckBox. | Can use Check Box. |
ComboBox Vs ListBox
LINQToSQL Vs Entity Framework
S.No | LINQTOSQL | Entity Framwork | |
1 | Used | rapid application development | enterprise application development. |
2 | Support | MS SQL Server database. | supports all existing ADO.NET data providers. |
3 | Relationship | One to One. | Many to Many. |
IEnumerable Vs IQuerable
S.No | IEnumerable | IQuerable | |
1 | namespace | Sysem.Collection | System.LINQ |
2 | query data | in-memory collections like List, Array etc. | out-memory (like remote database, service) collections. |
3 | suitable | LINQ to Object and LINQ to XML queries. | LINQ to SQL queries |
4 | supports | custom query. | custom query using CreateQuery and Execute methods |
5 | Extension methods | IEnumerable takes functional objects. | expression objects means expression tree. |
INTERSECT vs INNER JOIN
Both gave a same result. But One difference that is Column value is Null. Please see the Examples:
First create a temp Table in the Sql Server.
Example :1
Result for Example 1:
Inner Join -- No data displays.
INTERSECT -- Row displays.
Example --2:
Result for Example 1:
Inner Join -- No data displays.
INTERSECT -- No data displays.
I hope , you understand the difference between INTERSECT vs INNER JOIN
First create a temp Table in the Sql Server.
Example :1
Declare @m_table1 table (id int, firstName varchar(50))
Declare @m_table2 table (id int, firstName varchar(50))
-- Insert the ValueDeclare @m_table2 table (id int, firstName varchar(50))
Insert into @m_table1 values (1,NULL)
Insert into @m_table2 values (1,NULL)
-- Inner JoinInsert into @m_table2 values (1,NULL)
Select t1.*
from @m_table1 t1
inner join @m_table2 t2
On
t1.id=t2.id and t1.firstName=t2.firstName
-- INTERSECTfrom @m_table1 t1
inner join @m_table2 t2
On
t1.id=t2.id and t1.firstName=t2.firstName
Select * from @m_table1
INTERSECT
Select * from @m_table2
Result for Example 1:
Inner Join -- No data displays.
INTERSECT -- Row displays.
Example --2:
Declare @m_table1 table (id int, firstName varchar(50))
Declare @m_table2 table (id int, firstName varchar(50))
-- Insert the ValueDeclare @m_table2 table (id int, firstName varchar(50))
Insert into @m_table1 values (1,1)
Insert into @m_table2 values (1,NULL)
-- Inner JoinInsert into @m_table2 values (1,NULL)
Select t1.*
from @m_table1 t1
inner join @m_table2 t2
On
t1.id=t2.id and t1.firstName=t2.firstName
-- INTERSECTfrom @m_table1 t1
inner join @m_table2 t2
On
t1.id=t2.id and t1.firstName=t2.firstName
Select * from @m_table1
INTERSECT
Select * from @m_table2
Result for Example 1:
Inner Join -- No data displays.
INTERSECT -- No data displays.
I hope , you understand the difference between INTERSECT vs INNER JOIN
Labels:
Database
Function Name Format
Introduction:
Today, we discussed about function name format.
Today, we discussed about function name format.
CREATE FUNCTION FNNameformat(@colName varchar(max))
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @IntNumbers VARCHAR(MAX)
BEGIN
SET @IntNumbers = UPPER(LEFT(@colName ,1)) + LOWER(SUBSTRING(@colName,2,LEN(@colName)-1))
END
RETURN @IntNumbers
END
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @IntNumbers VARCHAR(MAX)
BEGIN
SET @IntNumbers = UPPER(LEFT(@colName ,1)) + LOWER(SUBSTRING(@colName,2,LEN(@colName)-1))
END
RETURN @IntNumbers
END
Labels:
Database
Extract Character from string in SQL
Today, we see the Extract character from String in SQL Server
Alter FUNCTION ExtractCharacter(@String VARCHAR(2000))
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @Count INT
DECLARE @IntNumbers VARCHAR(1000)
SET @Count = 0
SET @IntNumbers = ''
WHILE @Count <= LEN(@String)
BEGIN
IF SUBSTRING(@String,@Count,1) <> '0' AND SUBSTRING(@String,@Count,1) <> '1'
AND SUBSTRING(@String,@Count,1) <> '2' AND SUBSTRING(@String,@Count,1) <> '3'
AND SUBSTRING(@String,@Count,1) <> '4'AND SUBSTRING(@String,@Count,1) <> '5'
AND SUBSTRING(@String,@Count,1) <> '6' AND SUBSTRING(@String,@Count,1) <> '7'
AND SUBSTRING(@String,@Count,1) <> '8' AND SUBSTRING(@String,@Count,1) <> '9'
BEGIN
SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1)
END
SET @Count = @Count + 1
END
RETURN @IntNumbers
END
GO
Labels:
Database
Split Year,Month and Day from DateTime Column in SQL Server
Split Year,Month and Day from DateTime Column in SQL Server
Select YEAR(iddate) as [Year],Month(iddate) as [Month],Day(iddate) as date from Excel_Table where iddate!='' order by date Or Select DATEPART(YEAR,iddate) as [Year],DATEPART(Month,iddate) as [Month],DATEPART(Day,iddate) as date from Excel_Table where iddate!=''
Select YEAR(iddate) as [Year],Month(iddate) as [Month],Day(iddate) as date from Excel_Table where iddate!='' order by date Or Select DATEPART(YEAR,iddate) as [Year],DATEPART(Month,iddate) as [Month],DATEPART(Day,iddate) as date from Excel_Table where iddate!=''
Labels:
Database
Extract Number from string in SQL
Extract number from string in SQL
CREATE FUNCTION ExtractInteger(@String VARCHAR(2000))
RETURNS VARCHAR(1000)
AS
BEGIN DECLARE
@Count INT
DECLARE @IntNumbers VARCHAR(1000)
SET @Count = 0
SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1)
END SET @Count = @Count + 1
END RETURN @IntNumbers
END
GO
RETURNS VARCHAR(1000)
AS
BEGIN DECLARE
@Count INT
DECLARE @IntNumbers VARCHAR(1000)
SET @Count = 0
SET @IntNumbers = '' WHILE @Count <= LEN(@String) BEGIN IF SUBSTRING(@String,@Count,1) >= '0' AND SUBSTRING(@String,@Count,1) <= '9' BEGIN SET @IntNumbers = @IntNumbers + SUBSTRING(@String,@Count,1)
END SET @Count = @Count + 1
END RETURN @IntNumbers
END
GO
Labels:
Database
Display relationship tables in the SQL Database
Query for Display relationship tables in the SQL Database
SELECT f.name AS ForeignKey,SCHEMA_NAME(f.SCHEMA_ID) SchemaName,OBJECT_NAME(f.parent_object_id) AS TableName,
COL_NAME(fc.parent_object_id,fc.parent_column_id) AS ColumnName,SCHEMA_NAME(o.SCHEMA_ID) ReferenceSchemaName,OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,COL_NAME(fc.referenced_object_id,fc.referenced_column_id) AS ReferenceColumnNameFROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id INNER JOIN sys.objects AS o ON o.OBJECT_ID = fc.referenced_object_id
Labels:
Database
IEnumerable Vs Ilist
S.No | IEnumerable | List | |
1 | Add/Remove Items | doen’t support add or remove items from the list. | Supports add or remove items from the list. |
2 | Further Filtering | doesn’t support further filtering. | Supports further filtering. |