Tuesday, November 30, 2010

SQL Server Builtin functions to validate the data

Recently I came across a scenario in which I need to validate the data against the datatype.
After some searching I found the below SQL Server Builtin functions to validate the data.

ISNULL
ISNUMERIC
ISDATE
Eg:
SELECT ISNUMERIC('1234')--Returns 1 for success and 0 for failure.
SELECT ISDATE('11-30-2010')--Returns 1 for success and 0 for failure.

If you find relevant information, please update here so that I will publish with due credit.
Regards,
DP.

Sunday, November 21, 2010

Use of SQLCMD

Using SSMS, we can perform T-SQL batch operations on databases.
The same can be done using SQLCMD in appropriate situations.
1. Open command prompt and type sqlcmd -? to get the available commands information
2. sqlcmd -H 'hostname' -S 'servername' -D 'database'
3. Using sqlcmd -Q 'SQL query' and sqlcmd -q 'SQL query', batch operations can be achieved.

To know more about SQLCMD, please click link here.
Hope this post helps you,
Reference: DP (http://dptechnicalblog.blogspot.com/)

SQL PowerShell

SSMS has the object explorer using which we we can navigate to all components of database server.
The same can be achieved using T-SQL by using sqlps.exe i.e. SQL PowerShell

Syntax:
1.From run , type sqlps.exe, a pop opens
2. type dir to explore the available directory information
3. cd SQL to get the host information
4. cd 'db server', to explore the available components
5. cd databases
6. cd 'desired database name'

Reference: DP (http://dptechnicalblog.blogspot.com/)