Hi,
Here is the query to export the data from Excel to sqlserver
CREATE TABLE [dbo].[Addresses_Temp] (
[FirstName] VARCHAR(20),
[LastName] VARCHAR(20),
[Address] VARCHAR(50),
[City] VARCHAR(30),
[State] VARCHAR(2),
[ZIP] VARCHAR(10)
)
GO
INSERT INTO [dbo].[Address_Temp] ( [FirstName], [LastName], [Address], [City], [State], [ZIP] )
SELECT [FirstName], [LastName], [Address], [City], [State], [ZIP]
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Source\Addresses.xls;IMEX=1',
'SELECT * FROM [Sheet1$]')
To Access the function such as OPENROWSET Go to
MicroSoftSqlServer2005--->ConfigurationTools--->
SqlSurfaceAreaConfiguration
Click on Surface Area Configuration For features
and Enable OPENROWSET and OPENDATASOURCE support
Wednesday, May 20, 2009
Sunday, May 10, 2009
WildCharacters in Sql
Hi,
Here are the query results using Wild card Character.Consider below table
Student:
Now Consider the Query
Here are the query results using Wild card Character.Consider below table
Student:
Now Consider the Query
Select * from student Where Name like ‘John%’.
It return results as name starts with john . You will get the result as
Select * from student Where Name like ‘%John’. It results as
Select * from student Where Name like ‘%John%’. It results as
Select * from student Where Class like ‘Fo_r’. '_' matches single character and replace it
Friday, May 8, 2009
What is a flat file?
A flat file is the name given to text, which can be read or written only sequentially.
Calculate Age from the DateOfBirth
Hi,
Here is the program with the three line to calculate the age from the DOB
long yrs = 0;
DateTime bdayDate = new DateTime(2010, 07, 17);
TimeSpan ts = DateTime.Now.Subtract(bdayDate);
yrs = ts.Days / 365;
Response.Write(yrs);
Here is the program with the three line to calculate the age from the DOB
long yrs = 0;
DateTime bdayDate = new DateTime(2010, 07, 17);
TimeSpan ts = DateTime.Now.Subtract(bdayDate);
yrs = ts.Days / 365;
Response.Write(yrs);
Subscribe to:
Posts (Atom)