Friday, December 23, 2011

selecting multiple records from two tables

selecting multiple records from two tables

SELECT MIN(TableName) as TableName, ID, COL1, COL2, COL3 ...
FROM
(
SELECT 'Table A' as TableName, A.ID, A.COL1, A.COL2, A.COL3, ...
FROM A
UNION ALL
SELECT 'Table B' as TableName, B.ID, B.COL1, B.COl2, B.COL3, ...
FROM B
) tmp
GROUP BY ID, COL1, COL2, COL3 ...
HAVING COUNT(*) = 1
ORDER BY ID

union select two tables records

union select two tables records by anil nain sonipat haryana
select*from FAMILY whereEXISTS
(select*
from FAMILY_old
where FAMILY_old.Family_Id = FAMILY.Family_Id and FAMILY_old.Family_Score<=7
)and Edit_ind isnull
//////////////////////////////////////////////////////
update family set edit_ind=null where not EXISTS
(select *
from FAMILY_old
where FAMILY_old.Family_Id = FAMILY.Family_Id and FAMILY_old.Family_Score<=7
) and Edit_ind=1
/////////////////////jyada records dhundne ke liye////////
select * from FAMILY where not EXISTS
(select *
from FAMILY_old
where FAMILY_old.Family_Id = FAMILY.Family_Id and FAMILY_old.Family_Score<=7
) and Edit_ind=1

select FAMILY.family_id, FAMILY.form_no,FAMILY.house_number,FAMILY.Name_Of_Head, villages.Village_Name from FAMILY inner join villages on villages.Village_Code=family.Village_Code where EXISTS
(select *
from FAMILY_old
where FAMILY_old.Family_Id = FAMILY.Family_Id and FAMILY_old.Family_Score<=7
) and Edit_ind is null

union select two tables records by anil nain sonipat haryana

Monday, July 4, 2011

Oracle Connectivity and DISE installation and connectivity with oracle anil nain from sonipat




installation of Oracle and DISE and their Connectivity by anil nain from sonipat


when installation oracle give default is oracle8i


step 1 start- oracle8i Network Admin

Step2 net 8 config assit

local net service name

add

oracle8i

service name - oracle8i

hostname TCP- "computer name"


system

maneger

password and user name -dise2001

dise2001


Configration-create tables space

create user

DPCSonipat

DPCsnp

rename snp to disexpt



Oracle Run-------------

Run-sqlplus-internal/oracle-startup-Exit-Exit






Magerment Calculation and Startups

Calculating area of non square pl oat by anil nain sonipat
c
b a
d
Avg of b+a/2=x
Avg of c+d/2=y
x*y=z/9

3.5 Akkad=35000 gaze
35000*9=----Square feet
35000*9*.0924=---square meters

Monday, May 2, 2011

Define parameter for commands of SqlDataSource


Define parameter for commands of SqlDataSource by anil nain 9416077273
" runat="server">DeleteCommand="DELETE FROM [Company] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [Company] ([Title], [Address]) VALUES (@Title, @Address)"

SelectCommand="SELECT [ID], [Title], [Address] FROM [Company]"
UpdateCommand="UPDATE [Company] SET [Title] = @Title, [Address] = @Address WHERE [ID] = @ID">




<%--




--%>






Thursday, December 9, 2010

Splitting parts of file path using vb.net by anil nain


Splitting parts of file path using vb.net by anil nain 9416077273
Here we see how you can Split a file system path into separate parts using Visual Basic .NET. We use a New Char() array with one string, "\""c, and then loop through and display the results.=== Program that splits file path (VB.NET) ===
Module Module1
Sub Main()
' The file system path we need to split
Dim s As String = "C:\Users\Sam\Documents\Perls\Main"
' Split the string on the backslash character
Dim parts As String() = s.Split(New Char() {"\"c})
' Loop through result strings with For Each
Dim part As String
For Each part In parts
Console.WriteLine(part)
Next
End Sub
End Module
=== Output of the program ===
C:
Users
Sam
Documents
Perls
Main
How you can split based on words
Often you need to extract the words from a String or sentence in VB.NET. The code here needs to handle punctuation and non-word characters differently than the String Split method. Here we use Regex.Split to parse the words.=== Program that splits words (VB.NET) ===
Imports System.Text.RegularExpressions
Module Module1
Sub Main()
' Declare iteration variable
Dim s As String
' Loop through words in string
Dim arr As String() = SplitWords("That is a cute cat, man!")
' Display each word. Note that punctuation is handled correctly.
For Each s In arr
Console.WriteLine(s)
Next
Console.ReadLine()
End Sub
'''
''' Split the words in string on non-word characters.
''' This means commas and periods are handled correctly.
'''

Private Function SplitWords(ByVal s As String) As String()
'
' Call Regex.Split function from the imported namespace.
' Return the result array.
'
Return Regex.Split(s, "\W+")
End Function
End Module
=== Output of the program ===
That
is
a
cute
cat
man
Description of the example code. In the Main() subroutine you can see that two variables are declared. The second variable is a String() array that receives the results from the Private Function next.
Description of the Regex. The Function shown in the example calls the Regex.Split method, which can be accessed with dot notation, with no instance necessary. The second parameter to the method is a regular expression pattern.
Description of the Regex pattern. The pattern "\W+" is used, and this means "1 or more non-word characters". This pattern will match punctuation and spaces. Therefore, all those characters will be used as delimiters.
Splitting each line in a file
Here we see one way to Split each line in a file using File.ReadAllLines and Split. We have a comma-separated-values CSV file, and want to print out each value and its row number. Here is the input file "example.txt". Please see the below example.
The Split code example follows. It first reads in the file with ReadAllLines. This function puts each line in the file into an array element. The example next Splits on ","c. The final comment shows the output of the program.=== Input file used ===
frontal,parietal,occipital,temporal
pulmonary artery,aorta,left ventricle
=== Example program that splits lines (VB.NET) ===
Imports System.IO
Module Module1
Sub Main()
Dim i As Integer = 0
' Loop through each line in array returned by ReadAllLines
Dim line As String
For Each line In File.ReadAllLines("example.txt")
' Split line on comma
Dim parts As String() = line.Split(New Char() {","c})
' Loop over each string received
Dim part As String
For Each part In parts
' Display to Console
Console.WriteLine("{0}:{1}", i, part)
Next
i += 1
Next
End Sub
End Module
=== Output of the program ===
0:frontal
0:parietal
0:occipital
0:temporal
1:pulmonary artery
1:aorta
1:left ventricle
Splitting parts of file path using vb.net by anil nain

Saturday, August 28, 2010

Distributed Database कांसेप्ट्स बी अनिल NAIN


Distributed Database Concepts बी अनिल नैन 9416077273
Distributed database (DDB) - It is a collection of multiple logically interrelated databases distributed over a computer networks and a distributed database management system (DDBMS) as a software system that manages a distributed database while making tie distribution transparent to the user. A collection of files started at different nodes of network and the maintaining of Inter relationship among them via hyperlinks has become a common organisation on the internet, with file of web pages.
Advantages of Distributed Databases
Distributed database management has been proposed for various reason ranging from organizational, decentralisation and economical processing to greater autonomy. We highlight some of these advantages here.
1. Management of distributed data with different level of transparency: Ideally, a DBMS should be distribution transparent in the sense of hiding the details of where each file (table, relation) is physically stored within the system. Consider the company database that is spread over the network as shown in Figure 6.4.
Communication Network
Chicago (Headquarters)
New York
Atlanta
San Francisco
Los Angles

Employees - San Francisco and Los Angeles
Projects - San Francisco
Works_On - San Francisco Employee
Employees - ALL
Projects - ALL
Works_On - ALL
Employees - New York
Projects - ALL
Works_On - New York Employee
Employees - Atlanta
Projects - Atlanta
Works_On - Atlanta Employee
Employees - Los Angles
Projects - Los Angles and San Francisco
Works_On - Los Angles Employees
Where Employees, Projects and Works_ On are the relation in the Company Database as follows:
EMPLOYEE
FNAME
LANAME
SSN
BDATE
ADDRESS
SEX
SALARY
PROJECT
PNAME
PNUMBER
PLOCATION
DNUM
WORKS_ON
ESSN
PNO
HOURS


· Distributed or network transparency: This refers to freedom for the user from the operational details of the network. It may be divided into location transparency and naming transparency.
Location transparency: It refers to the fact that the command used to perform a task is independent of the location of data and the location of the system where the command was issued.
Naming Transparency: It implies that once a name is specified, the named objects can be accessed unambiguously without additional specification
· Replication transparency: As we show in above figure copies of data may be stored at multiple sites for better availability, performance, and reliability. Replication transparency makes the user unaware of the existence of copies.
· Fragmentation transparency: Two types of fragmentation are possible. Horizontal fragmentation distributes a relation into sets of tuples (rows) and Vertical fragmentation distributes a relation into sub relation where each sub relation is defined by a subset of the column of the original relation. A global query by the user must be transformed into several payment queries. Fragmentation transparency makes the user unaware of the existence of fragments.
1. Increased reliability and availability: Reliability is broadly defined as the probability that a system is running (not down) at a certain point of time, whereas availability is the probability that the system is continuously available during a time interval. When the data and DBMS software are distributed over several sites, one site may fail while other sites continue to operate. Only the data and software that exists at the failed site cannot be accessed. In a centralised system, failure at a single site makes the whole system unavailable to all users.
2. Improved performance: A DDBMS fragments the database by keeping the data closer to where it is needed most. Data localisation reduces the contention for CPU and I/O services and simultaneously reduces access delays involved in Wide Area Network. When a large database is distributed over multiple sites, smaller database exist at each site. As a result, local queries and transactions accessing data at a single site have better performance because of the smaller local databases.
3. Easier Expansion: In a distributed environment, expansion of the system in terms of addition of more data, increasing database size, or addition of more processors is much easier.
Additional Functions of Distributed Databases
Distribution leads to increased complicity in system designed implementation. To achieve the potential advantage by DDBMS as listed previously, software must be able to provide the following functions in addition to those of a centralised DBMS.
Keeping track of data: The ability to keep track of the data distribution, fragmentation, and replication by expanding the DDBMS catalog.
Distributed query processing: The ability to access remote sites and transmit queries and data among the various sites via a communication network.
Distributed transaction management: The ability to devise execution strategies for queries and transactions that access data from more than one site and to synchronise the access to distributed data and maintain integrity of the overall database.
Replicated data management: The ability to decide which copy of a replicated data item to access and to maintain the consistency of copies of replicated data items.
Distributed database recovery: The ability to recover from individual crashes and from new types of failures such as the failure of a communication links.
Security: Distributed transactions must be executed with the proper management of the security of the data and the authorisation/access privileges of users.
Distributed directory (catalog) management: A directory contains information(meta data) about data in the database. The directory may be global for the entire DDB or local for each site. At the physical hardware level, the following main factors distinguish a DDBMS from a centralised system.
There are multiple computers, called sites or nodes.