Programming with Talha Tanweer
Asp.net
Ado.net
C#
Sql
Entity Framework
Articles
Question & answers
Forums
How to
Monday, 12 May 2014
Round values to N number of Decimal points in sql server
Round (expression , length)
SELECT
ROUND
(
3.1415
,
2
)
-- 3.14
SELECT
ROUND
(
33.234234234
,
1
)
-- 33.2
SELECT
ROUND
(
55.6345345
,
0
)
-- 56
Monday, 31 March 2014
Find Length of string with LEN function in sql server
It returns the number of characters of string expression but with excluding trailing blanks.
SELECT
LEN
(
'Sql Server Database'
)
-- Result : 19
Thursday, 27 March 2014
Get List of all tables of a database in sql server
SELECT
*
from
sys
.
tables
Wednesday, 26 March 2014
Get List of all stored procedures of a database in sql server
SELECT
*
from
sys
.
procedures
Tuesday, 25 March 2014
Find Age from Date of Birth in Sql Server
declare
@dob
datetime
=
'1952-08-14 21:11:19.300'
select
CAST
(
DATEDIFF
(
Y
,
@dob
,
getdate
()
)/
365.25
as
int
)
-
- 365 are the Number of Average days in 4 years
Sunday, 23 March 2014
Select Top N rows from a table in Sql Server
Suppose if N=10 then ,
Select
Top
10
*
from
Person
IF you want to Select only particular columns then,
Select
Top
10
Name
,
City
,
Age
from
Person
Get current system date in Sql Server
SELECT
GETDATE
()
-- Result : 2014-03-23 19:57:21.630
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)