Thursday, March 10, 2011
DatePart, DATEFIRST, @@DateFirst in Sql Server.
The weekday in sql server is represented as
Monday = 1
Tuesday = 2
Wednesday = 3
.....
Sunday = 7
So, by default the Sunday(7) is set as the first day of the day.
So the query SELECT DATEPART(dw,'2011-03-09 20:28:36.090')
which falls on wednesday returns 4(Sunday-1.... Wednesday - 4)
you can set any day of the week to be the first day of the Week. Below is the syntax to do that
SET DATEFIRST 1 //Sets monday as the first day of the week
SELECT @@DATEFIRST //return 1
SELECT @@DATEFIRST //return 1
SELECT DATEPART(dw,'2011-03-09 20:28:36.090') //return 3, since Monday is already set as default which is 1.
For more information on datepart
http://msdn.microsoft.com/en-us/library/ms174420.aspx
Hope it would have helpful to you..
Labels:
SQL Server
Wednesday, March 2, 2011
Commands
Deleting a service
sc /delete "service name"
Starting and stopping a service
net start
net stop
Run Commands
ssms - Opens the SQL SERVER 2008.
services.msc - Opens the services window.
shutdown - shut down windows.
acrobat - Acrobat Reader.
photoshop - Adobe Photoshop.
eventvwr.msc - Event Viewer Manager.
firefox - firefox.
iexplore - Internet Explorer.
inetcpl.cpl - Internet Properties.
msaccess - Microsoft Access.
excel - Microsoft Excel.
mspaint - Paint.
powerpnt - Powerpoint.
MSTSC - Remote desktop.
winword - Word.
regedit32 - Windows Registry.
control schedtasks- Scheduled Tasks.
fsmgmt.msc - Shared Folder Management.
write - Wordpad.
notepad - Notepad.
ssms - Opens the SQL SERVER 2008.
services.msc - Opens the services window.
shutdown - shut down windows.
acrobat - Acrobat Reader.
photoshop - Adobe Photoshop.
eventvwr.msc - Event Viewer Manager.
firefox - firefox.
iexplore - Internet Explorer.
inetcpl.cpl - Internet Properties.
msaccess - Microsoft Access.
excel - Microsoft Excel.
mspaint - Paint.
powerpnt - Powerpoint.
MSTSC - Remote desktop.
winword - Word.
regedit32 - Windows Registry.
control schedtasks- Scheduled Tasks.
fsmgmt.msc - Shared Folder Management.
write - Wordpad.
notepad - Notepad.
regedit - Registry.
Visio - Microsoft Visio.
Explorer - Windows Explorer.
inetmgr - IIS.
Control Panel - control.
Visio - Microsoft Visio.
Explorer - Windows Explorer.
inetmgr - IIS.
Control Panel - control.
Labels:
Windows
Tuesday, March 1, 2011
How to move the LINQ - dbml file to production server.
Usually we know that the dbml acts as an interface between the database and user interface for getting connected with the database.
We create the dbml file in our development system and itz quite obvious that the dbml file will directly point to our development database.
What if we move our application into to the production server there the database server will be pointing to the different location. So we need to manually write a code to point to the production database.
Here is the steps which you need to follow.
1. Open the LINQ project.
2. Open the Properties in that go to the file Settings.settings -> Settings.designer.cs file.
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=SIVA-HOME\\SQL2005;Initial Catalog=Inventory;Persist Securi" +
"ty Info=True;User ID=sa;Password=2121212")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=SIVA-HOME\\SQL2005;Initial Catalog=Inventory;Persist Securi" +
"ty Info=True;User ID=sa;Password=2121212")]
public string FreeFlockServiceConnectionString {
get {
//this is the place which concerns us, this is value which is auto generated
//this is auto-generated by the dbml file
// return ((string)(this["FreeFlockServiceConnectionString"]));
// return ((string)(this["FreeFlockServiceConnectionString"]));
//create a code which point to the database from the web.config
return ((string)(System.Configuration.ConfigurationManager.ConnectionStrings["FreeFlockServiceConnectionString"].ConnectionString));
}
}
return ((string)(System.Configuration.ConfigurationManager.ConnectionStrings["FreeFlockServiceConnectionString"].ConnectionString));
}
}
3. Create a connection string tag in the web.config which is pointing to the production server database.
Thatz cool rite!!!!
Labels:
LINQ
Subscribe to:
Posts (Atom)