SELECT * FROM
students WHERE email NOT
LIKE '%_@__%.__%'
Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts
Friday, 31 August 2012
Saturday, 18 August 2012
Sunday, 5 August 2012
how to get last record value in sql server without using MAX/TOP clause?
1)SELECT * FROM tablename WHERE primarykeyid= IDENT_CURRENT('tablename')
Eg:
SELECT * FROM tbl_emp WHERE empid= IDENT_CURRENT('tbl_emp ')
2)
set rowcount 1
select * from tbl_emp order by
empid desc
SET ROWCOUNT { number | @number_var }
Causes SQL Server to stop processing the query after the specified number of rows are returned.
Labels:
sql
Sunday, 8 July 2012
sql - Check length of a string
Length
of VARCHAR fields the function LEN(varcharfield) is useful.
Length of TEXT fields the function is DATALENGTH(textfield).
Len will not work for text field.
Example:
SELECT
LEN
(
yourvarcharfield
)
AS
VarcharFieldSize
SELECT
DATALENGTH
(
yourtextfield
)
AS TEXT
FieldSize
Labels:
sql
Subscribe to:
Posts (Atom)