Friday, June 3, 2011

Hi All,

We find one validation expression where you can use it by your own,

Ex: 1 ValidationExpression="^[A-Z ]+"

in aboce exaple i want only character With Upper Case so i can enter only upper case character

Ex: 1 ValidationExpression="^[0-9 ]+"

in aboce exaple i want only Numbers so i can enter only Numbers using aboce statement

example where special character not allowed

ValidationExpression="^[a-zA-Z0-9 ]+"




Hope it will helop youi all!!!!!!!!!!!!!!!!!!!!!!!!

Friday, May 6, 2011

select records with comma

use full query for searching records base on , request

select * from msttest WHERE ',' + testfield1 + ',' LIKE '%,11,%' or testfield1 in('11','12')

Tuesday, April 26, 2011

Access denied in XML files

Hi Dosto,

few days ago , i was so frustrated because i am getting "Access denied Error in Asp .net Project,
after doing lots of R&D i got sucess, whenever you do XML Operation always put

before

here
accountname = server name like adminisrator
password = your server password which u used for remote login



Tuesday, March 22, 2011

SQL SERVER - Create Script to Copy full Database including SP, Trigger,Views ,function & all

How t0 take copy of database including all objects///////

here is the solution

Step 1 : Start

Step 2 : Welcome Screen

Step 3 : Select One or Multiple Database
If Script all objects in the selected database checkbox is not selected it will give options to selected individual objects on respective screen. (e.g. Stored Procedure, Triggers and all other object will have their own screen where they can be selected)

Step 4 : Select database options

Step 5 : Select output option

Step 6 : Review Summary

Step 7 : Observe script generation process

Step 8 : Database object script generation completed in new query window

Saturday, March 5, 2011

Casting Solution

Recently My friend Manoj sharma faced a issue in casting, so here are few question Answers which help you related to casting


Few of the questions I receive very frequently. I have collect them in spreadsheet and try to answer them frequently.

How to convert text to integer in SQL?
If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function.

How to use CAST or CONVERT?
SELECT CAST(YourVarcharCol AS INT) FROM Table
SELECT CONVERT(INT, YourVarcharCol) FROM Table

Will CAST or CONVERT thrown an error when column values converted from alpha-numeric characters to numeric?
YES.

Will CAST or CONVERT retrieve only numbers when column values converted from alpha-numeric characters to numeric?
NO.

SQL DATE TIME

There are 3 ways for retrieving the current datetime in SQL SERVER.

which is

1 ..CURRENT_TIMESTAMP,

2..GETDATE(),

3..{fn NOW()}

CURRENT_TIMESTAMP
CURRENT_TIMESTAMP is a nondeterministic function. Views and expressions that reference this column cannot be indexed. CURRENT_TIMESTAMP can be used to print the current date and time every time that the report is produced.

GETDATE()
GETDATE is a nondeterministic function. Views and expressions that reference this column cannot be indexed. GETDATE can be used to print the current date and time every time that the report is produced.

{fn Now()}
The {fn Now()} is an ODBC canonical function which can be used in T-SQL since the OLE DB provider for SQL Server supports them. {fn Now()} can be used to print the current date and time every time that the report is produced.

If you run following script in Query Analyzer. I will give you same results. If you see execution plan there is no performance difference. It is same for all the three select statement.
SELECT CURRENT_TIMESTAMP
GO
SELECT {fn NOW()}
GO
SELECT GETDATE()
GO

Performance:
There is absolutely no difference in using any of them. As they are absolutely same.

My Preference:
I like GETDATE(). Why? Why bother when they are same!!!

Wednesday, January 26, 2011

Joins in SQL

Dear Friends,

Some time we got problems in views , when we run default views it shows all records from both the table, if we want only records from one table always use RIGHT JOIN or LEFT JOIN
it will shows only one table record.

if you want to show all records (Not only matching records) use Right join or Left Join

Sample View

SELECT dbo.view_DistCommission.
inttransectioncode AS Expr3, dbo.mstreport.ReferenceNo, dbo.mstreport.MerchantID AS Expr2,
dbo.view_DistCommission.intrdsbooking, dbo.view_DistCommission.transectiondate, dbo.view_DistCommission.distributorcode,
dbo.view_DistCommission.customername, dbo.view_DistCommission.strstatus, dbo.view_DistCommission.createddatetime,
dbo.view_DistCommission.Expr1, dbo.view_DistCommission.strAgencyName, dbo.view_DistCommission.b2cdistributortac,
dbo.view_DistCommission.b2cagenttac, dbo.view_DistCommission.transectionstatus, dbo.view_DistCommission.offerprice,
dbo.view_DistCommission.agentcode, dbo.view_DistCommission.publishedprice, dbo.view_DistCommission.Description,
dbo.view_DistCommission.product, dbo.view_DistCommission.strmerchantcode, dbo.view_DistCommission.merchantid,
dbo.view_DistCommission.TDS, dbo.view_DistCommission.inttransectioncode
FROM dbo.view_DistCommission LEFT OUTER JOIN
dbo.mstreport ON dbo.view_DistCommission.inttransectioncode = dbo.mstreport.strtransectionid
GROUP BY dbo.view_DistCommission.inttransectioncode, dbo.mstreport.ReferenceNo, dbo.mstreport.MerchantID, dbo.view_DistCommission.intrdsbooking,
dbo.view_DistCommission.transectiondate, dbo.view_DistCommission.distributorcode, dbo.view_DistCommission.customername,
dbo.view_DistCommission.strstatus, dbo.view_DistCommission.createddatetime, dbo.view_DistCommission.Expr1,
dbo.view_DistCommission.strAgencyName, dbo.view_DistCommission.b2cdistributortac, dbo.view_DistCommission.b2cagenttac,
dbo.view_DistCommission.transectionstatus, dbo.view_DistCommission.offerprice, dbo.view_DistCommission.agentcode,
dbo.view_DistCommission.publishedprice, dbo.view_DistCommission.Description, dbo.view_DistCommission.product,
dbo.view_DistCommission.strmerchantcode, dbo.view_DistCommission.merchantid, dbo.view_DistCommission.TDS


Thanks
Pradeep Deokar