Field | Expression | Format Samples | Description |
---|---|---|---|
Name | ^[a-zA-Z''-'\s]{1,40}$ | John Doe O'Dell | Validates a name. Allows up to 40 uppercase and lowercase characters and a few special characters that are common to some names. You can modify this list. |
Social Security Number | ^\d{3}-\d{2}-\d{4}$ | 111-11-1111 | Validates the format, type, and length of the supplied input field. The input must consist of 3 numeric characters followed by a dash, then 2 numeric characters followed by a dash, and then 4 numeric characters. |
Phone Number | ^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$ | (425) 555-0123 425-555-0123 425 555 0123 1-425-555-0123 | Validates a U.S. phone number. It must consist of 3 numeric characters, optionally enclosed in parentheses, followed by a set of 3 numeric characters and then a set of 4 numeric characters. |
^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$ | someone@example.com | Validates an e-mail address. | |
URL | ^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$ | http://www.microsoft.com | Validates a URL |
ZIP Code | ^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$ | 12345 | Validates a U.S. ZIP Code. The code must consist of 5 or 9 numeric characters. |
Password | (?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$ | Validates a strong password. It must be between 8 and 10 characters, contain at least one digit and one alphabetic character, and must not contain special characters. | |
Non- negative integer | ^\d+$ | 0 986 | Validates that the field contains an integer greater than zero. |
Currency (non- negative) | ^\d+(\.\d\d)?$ | 1.00 | Validates a positive currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point. For example, 3.00 is valid but 3.1 is not. |
Currency (positive or negative) | ^(-)?\d+(\.\d\d)?$ | 1.20 | Validates for a positive or negative currency amount. If there is a decimal point, it requires 2 numeric characters after the decimal point. |
Search This Blog
Tuesday, November 30, 2010
Common Regular Expressions
Common Regular Expressions
Thursday, November 25, 2010
How to find all tables and its definition in current sql database
Below query will show you all tables definition with column details.
SELECT
SysObjects.[Name] as TableName,
SysColumns.[Name] as ColumnName,
SysTypes.[Name] As DataType,
SysColumns.[Length] As Length
FROM SysObjects
INNER JOIN SysColumns ON SysObjects.[Id] = SysColumns.[Id]
INNER JOIN SysTypes ON SysTypes.[xtype] = SysColumns.[xtype]
WHERE
SysObjects.[type] = 'U'
ORDER BY SysObjects.[Name]
SysObjects.[Type] value's details
1: C = CHECK constraint
2: D = Default or DEFAULT constraint
3: F = FOREIGN KEY constraint
4: FN = Scalar function
5: IF = Inlined table-function
6: K = PRIMARY KEY or UNIQUE constraint
7: L = Log
8: P = Stored procedure
9: R = Rule
10: RF = Replication filter stored procedure
11: S = System table
12: TF = Table function
13: TR = Trigger
14: U = User table
15: V = View
16: X = Extended stored procedure
SELECT
SysObjects.[Name] as TableName,
SysColumns.[Name] as ColumnName,
SysTypes.[Name] As DataType,
SysColumns.[Length] As Length
FROM SysObjects
INNER JOIN SysColumns ON SysObjects.[Id] = SysColumns.[Id]
INNER JOIN SysTypes ON SysTypes.[xtype] = SysColumns.[xtype]
WHERE
SysObjects.[type] = 'U'
ORDER BY SysObjects.[Name]
SysObjects.[Type] value's details
1: C = CHECK constraint
2: D = Default or DEFAULT constraint
3: F = FOREIGN KEY constraint
4: FN = Scalar function
5: IF = Inlined table-function
6: K = PRIMARY KEY or UNIQUE constraint
7: L = Log
8: P = Stored procedure
9: R = Rule
10: RF = Replication filter stored procedure
11: S = System table
12: TF = Table function
13: TR = Trigger
14: U = User table
15: V = View
16: X = Extended stored procedure
Wednesday, November 24, 2010
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during ..
"Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request"
When you are using FormView with ItemTemplate , InsertItemTemplate and EditItemTemplate and you click any event like save, update or delete. After this you click on any postback control then you may get the above exception.
Cause: All template FormView may have different control definition e.g. ItemTemplate does not match control definition with IsertItemTemplate or EditItemTemplate(number of controls or mismatch of control ids')
Solution: Try to keep same control definition in all template
Note: Try to not include ItemTemplate in your FormView
When you are using FormView with ItemTemplate , InsertItemTemplate and EditItemTemplate and you click any event like save, update or delete. After this you click on any postback control then you may get the above exception.
Cause: All template FormView may have different control definition e.g. ItemTemplate does not match control definition with IsertItemTemplate or EditItemTemplate(number of controls or mismatch of control ids')
Solution: Try to keep same control definition in all template
Note: Try to not include ItemTemplate in your FormView
Tuesday, November 16, 2010
System Error Codes
Click below link to see System Error codes:
http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx
Monday, November 8, 2010
Backup ALL your SQL Server 2005 databases using ONE script
DECLARE @DBName varchar(255)
DECLARE @DATABASES_Fetch int
DECLARE DATABASES_CURSOR CURSOR FOR
select
DATABASE_NAME = db_name(s_mf.database_id)
from
sys.master_files s_mf
where
-- ONLINE
s_mf.state = 0
-- Only look at databases to which we have access
and has_dbaccess(db_name(s_mf.database_id)) = 1
-- Not master, tempdb or model
and db_name(s_mf.database_id) not in ('Master','tempdb','model','ReportServer$SQL2K5','ReportServer$SQL2K5TempDB')
group by s_mf.database_id
order by 1
OPEN DATABASES_CURSOR
FETCH NEXT FROM DATABASES_CURSOR INTO @DBName
WHILE @@FETCH_STATUS = 0
BEGIN
declare @DBFileName varchar(256)
set @DBFileName = datename(dw, getdate()) + ' - ' +
replace(replace(@DBName,':','_'),'\','_')
exec ('BACKUP DATABASE [' + @DBName + '] TO DISK = N''E:\DatabaseBACKUP\' +
@DBFileName + ''' WITH NOFORMAT, INIT, NAME = N''' +
@DBName + '-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 100')
FETCH NEXT FROM DATABASES_CURSOR INTO @DBName
END
CLOSE DATABASES_CURSOR
DEALLOCATE DATABASES_CURSOR
DECLARE @DATABASES_Fetch int
DECLARE DATABASES_CURSOR CURSOR FOR
select
DATABASE_NAME = db_name(s_mf.database_id)
from
sys.master_files s_mf
where
-- ONLINE
s_mf.state = 0
-- Only look at databases to which we have access
and has_dbaccess(db_name(s_mf.database_id)) = 1
-- Not master, tempdb or model
and db_name(s_mf.database_id) not in ('Master','tempdb','model','ReportServer$SQL2K5','ReportServer$SQL2K5TempDB')
group by s_mf.database_id
order by 1
OPEN DATABASES_CURSOR
FETCH NEXT FROM DATABASES_CURSOR INTO @DBName
WHILE @@FETCH_STATUS = 0
BEGIN
declare @DBFileName varchar(256)
set @DBFileName = datename(dw, getdate()) + ' - ' +
replace(replace(@DBName,':','_'),'\','_')
exec ('BACKUP DATABASE [' + @DBName + '] TO DISK = N''E:\DatabaseBACKUP\' +
@DBFileName + ''' WITH NOFORMAT, INIT, NAME = N''' +
@DBName + '-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 100')
FETCH NEXT FROM DATABASES_CURSOR INTO @DBName
END
CLOSE DATABASES_CURSOR
DEALLOCATE DATABASES_CURSOR
Subscribe to:
Posts (Atom)