Monday, 30 April 2012

Get the Day Name from Date In SQL SERVER

In SQL
select datename (dw, '4/30/2012') as NameOfDay  --dw is refer as DATEPART
 the result is 'Monday'

 From this we can find the day of Date...
datepart
Is the parameter that specifies the part of the date to return. The following table lists dateparts and abbreviations recognized by Microsoft SQL Server 2005.
Datepart Abbreviations
year
yy, yyyy
quarter
qq, q
month
mm, m
dayofyear
dy, y
day
dd, d
week
wk, ww
weekday
dw
hour
hh
minute
mi, n
second
ss, s
millisecond
ms
The weekday (dw) datepart returns the day of the week, such as Sunday, Monday, and so on.
 http://msdn.microsoft.com/en-us/library/ms174395%28v=sql.90%29.aspx


Friday, 27 April 2012

About subquery in SQL Server

A subquery can be nested inside the WHERE or HAVING clause of an outer SELECT, INSERT, UPDATE, or DELETE statement, or inside another subquery. Up to 32 levels of nesting is possible, although the limit varies based on available memory and the complexity of other expressions in the query. Individual queries may not support nesting up to 32 levels. A subquery can appear anywhere an expression can be used, if it returns a single value.

how to enable 'sa' login in sql server 2005

step 1 , login as windows authenticatin mode, using  'Administrator' login.
step2, Then go to 'Object Explorer'
step 3, Find Security menu from that. Then find Login
step 4,  From Login menu select 'sa' --> properties.
step 5, in left site find the status and make enable in right side. also set the password in General section.

Note:
 it is possible to login failed for windows authentication mode. For this problem there is a possible low disk space in ms sql server installed drive. so make free space then restart computer then attempt to login. it will fine.