<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SQLPuli</title>
	<atom:link href="http://sinshith.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sinshith.wordpress.com</link>
	<description>Sinshith's Blog on SQL Server.</description>
	<lastBuildDate>Sun, 04 Jul 2010 04:09:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sinshith.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>SQLPuli</title>
		<link>http://sinshith.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sinshith.wordpress.com/osd.xml" title="SQLPuli" />
	<atom:link rel='hub' href='http://sinshith.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Query for finding the Execution time of SPs</title>
		<link>http://sinshith.wordpress.com/2010/06/07/query-for-finding-the-execution-time-of-sps/</link>
		<comments>http://sinshith.wordpress.com/2010/06/07/query-for-finding-the-execution-time-of-sps/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 13:32:46 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=79</guid>
		<description><![CDATA[Query for finding the Execution time of SPs DECLARE @V3 DATETIME DECLARE @V1 DATETIME DECLARE @V2 DATETIME SET @V1= GETDATE() SELECT CONVERT(TIME,@V1) START_TIME EXEC SP_NAME @PARAM= &#8221; SET @v2=GETDATE() SELECT CONVERT(TIME,@V2) END_TIME SELECT @V3=@V2-@V1 SELECT CONVERT(TIME,@V3) DIFF The above query will give an accurate result with start time,end time,execution time&#8230;..<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=79&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Query for finding the Execution time of SPs</p>
<p>DECLARE @V3 DATETIME<br />
DECLARE @V1 DATETIME<br />
DECLARE @V2 DATETIME<br />
SET @V1= GETDATE()<br />
SELECT CONVERT(TIME,@V1) START_TIME<br />
EXEC SP_NAME @PARAM= &#8221;<br />
SET @v2=GETDATE()<br />
SELECT CONVERT(TIME,@V2) END_TIME<br />
SELECT @V3=@V2-@V1<br />
SELECT CONVERT(TIME,@V3) DIFF</p>
<p>The above query will give an accurate result with start time,end time,execution time&#8230;..</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=79&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2010/06/07/query-for-finding-the-execution-time-of-sps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Database Migration</title>
		<link>http://sinshith.wordpress.com/2010/04/21/database-migration/</link>
		<comments>http://sinshith.wordpress.com/2010/04/21/database-migration/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 06:37:38 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/2010/04/21/database-migration/</guid>
		<description><![CDATA[Migration of Database One of the usual tasks done by the DB developers is DB Migration. Migration is nothing but transfer of data from one database to another. Its not always easy if the data need to be migrated to be appended on the target database. Appending means nothing but add the unavailable data from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=78&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Migration of Database</p>
<p>One of the usual tasks done by the DB developers is DB Migration. Migration is nothing but transfer of data from one database to another. Its not always easy if the data need to be migrated to be appended on the target database.<br />
Appending means nothing but add the unavailable data from first database in to target database.</p>
<p>Steps for migration</p>
<p>1.	First step for migration understands the Source database. The process includes drawing of a simple Entity relationship diagram for the source database. There will be an important table with an important column which spread across the database. May be more than one table. Our first duty is to identify such tables and the relations. Also we need to identify the static tables. which may be migrated manually .And identification of identity columns and turning on the IDENTITY_INSERT property also important.</p>
<p>2.	On next step we have to create an SP for migration. Most important variable which can be taken as the parameter. Select all the columns from the related tables can be put into temporary tables .Dont forget to add conditions while putting the values in temporary tables.<br />
After that we can write the insert statements. and last we can drop the temporary tables.</p>
<p>For eg.</p>
<p>CREATE PROCEDURE PRO_NAME<br />
(<br />
PARAMETER1<br />
)<br />
AS<br />
SELECT<br />
COL1,<br />
COL2….<br />
INTO #TEMPTABLE<br />
FROM SOURCE TABLE<br />
WHERE CONDITIONS</p>
<p>SELECT<br />
COL1,<br />
COL2….<br />
INTO #TEMPTABLE<br />
FROM PARENT TABLE<br />
WHERE CONDITIONS</p>
<p>INSERT INTO DEST TABLE<br />
(<br />
COL1,<br />
COL2….<br />
)<br />
SELECT<br />
COL1,<br />
COL2….<br />
FROM #TEMPTABLE<br />
WHERE CONDITIONS</p>
<p>DROP ALL TEMPEROTY TABLES</p>
<p>Test it with a single value check whether any truncations happenings on the output </p>
<p>3.	We can automate the migration using cursors</p>
<p>SELECT col1 INTO temp FROM source</p>
<p>DECLARE @V1 VARCHAR(200)<br />
DECLARE @V2 VARCHAR(200)<br />
DECLARE CUR CURSOR<br />
FOR SELECT col1 FROM # temp<br />
OPEN CUR<br />
FETCH NEXT FROM CUR INTO @V1<br />
WHILE(@@FETCH_STATUS=0)<br />
BEGIN<br />
exec sp @V1<br />
FETCH NEXT FROM CUR INTO @V1<br />
END<br />
CLOSE CUR<br />
DEALLOCATE CUR</p>
<p>4.	We may need to write more than one SP for migration process.</p>
<p>Make sure that all data is migrated successfully .Dont forget to take statistics also.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=78&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2010/04/21/database-migration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>BulkInsert Process</title>
		<link>http://sinshith.wordpress.com/2010/04/12/bulkinsert-process/</link>
		<comments>http://sinshith.wordpress.com/2010/04/12/bulkinsert-process/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 14:04:07 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=72</guid>
		<description><![CDATA[Bulkinsert process Introduction Usually if we want to Tranfer a text file into a DB table,There are two ways 1.Using SSIS 2.Using SQL 1.Using SSIS We can use BulkInsert Task or Simple Dataflow task for this process. 2.Using SQL We can use bcp,Openrowset or Bulkinsert Scope of this document explains the use of Bulkinsert command. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=72&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste"><strong>Bulkinsert process</strong></div>
<div><strong><br />
</strong></div>
<div id="_mcePaste">Introduction</div>
<div id="_mcePaste">Usually if we want to Tranfer a text file into a DB table,There are two ways</div>
<div id="_mcePaste">1.Using SSIS</div>
<div id="_mcePaste">2.Using SQL</div>
<div id="_mcePaste">1.Using SSIS</div>
<div id="_mcePaste">We can use BulkInsert Task or Simple Dataflow task for this process.</div>
<div id="_mcePaste">2.Using SQL</div>
<div id="_mcePaste">We can use bcp,Openrowset or Bulkinsert</div>
<div id="_mcePaste">Scope of this document explains the use of Bulkinsert command.</div>
<div id="_mcePaste">Usually we prefer Bulkinsert because it is Faster and we can include many functions while Dataloading</div>
<div id="_mcePaste">The various steps included in the Dataloading are</div>
<div id="_mcePaste">1.Creation of Temperory or dummy table</div>
<div id="_mcePaste">2.Data loading to the Temperory table</div>
<div id="_mcePaste">3.Creation of actual table</div>
<div id="_mcePaste">4.Transfering data from Temperory table to Actual table</div>
<div id="_mcePaste">5.Droping of all temperory objects</div>
<div id="_mcePaste">1.Creation of Temperory or dummy table</div>
<div id="_mcePaste">This process includes the creation of Temperory table.Here temperory table means the actual physical table.It is not</div>
<div id="_mcePaste">advisable to use #table if we are loading Huge data.While using the Bulkinsert task we have to remove all Identity column</div>
<div id="_mcePaste">or default column if it is not available in the row data.And it is advisable to give large values(eg. varchar(1000)</div>
<div id="_mcePaste">for the first and last columns because there may be unusable vacant space at the end of each row.</div>
<div id="_mcePaste">2.Data loading to the Temperory table</div>
<div id="_mcePaste">Once temperory table is created we can load the data in to the Temperory table.We can have look on the Source data before</div>
<div id="_mcePaste">loading(If the data is more than 1 GB i recomend Jujuedit to view the content)</div>
<div id="_mcePaste">In normal case we use direct script to load the data</div>
<div id="_mcePaste">ie for eg.</div>
<div id="_mcePaste">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">BULK INSERT TEST_TABLE</div>
<div id="_mcePaste">FROM ‘Test_data.txt’</div>
<div id="_mcePaste">WITH</div>
<div id="_mcePaste">(</div>
<div id="_mcePaste">FIELDTERMINATOR =’,&#8217;,</div>
<div id="_mcePaste">ROWTERMINATOR = ‘\n’</div>
<div id="_mcePaste">)</div>
<div id="_mcePaste">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">This is the script we use in Ideal situations like..If the row data dont have any header. or the row data generated</div>
<div id="_mcePaste">not by a unix machine where ROWTERMINATOR is not ‘\n’.</div>
<div id="_mcePaste">FIELDTERMINATOR is nothing but the character used to seperate each fields in the given examle its a comma.</div>
<div id="_mcePaste">ROWTERMINATOR is nothing but the entity which seperates each row in ideal case it will be newline character ‘\n’</div>
<div id="_mcePaste">we can enforce identity ,Unique constraint,primary key constraint or NOT NULL constraint by including KEEPIDENTITY</div>
<div id="_mcePaste">or CHECK_CONSTRAINT inside the bracket.</div>
<div id="_mcePaste">But we may not be lucky in all the cases.If the data is generated by a Unix based machine then the ideal query will</div>
<div id="_mcePaste">not work.So we have to use a special dynamic query</div>
<div id="_mcePaste">ie for eg.</div>
<div id="_mcePaste">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">declare @sql nvarchar(4000)</div>
<div id="_mcePaste">set @sql =</div>
<div id="_mcePaste">‘BULK INSERT Dest_table</div>
<div id="_mcePaste">FROM ”\\Loc ”</div>
<div id="_mcePaste">WITH</div>
<div id="_mcePaste">(</div>
<div id="_mcePaste">FIRSTROW = 2,</div>
<div id="_mcePaste">FIELDTERMINATOR = ”|”,</div>
<div id="_mcePaste">ROWTERMINATOR = ”’ + nchar(10) + ”’ ,</div>
<div id="_mcePaste">LASTROW=3355072</div>
<div id="_mcePaste">)’</div>
<div id="_mcePaste">select @sql</div>
<div id="_mcePaste">exec(@sql)</div>
<div id="_mcePaste">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</div>
<div id="_mcePaste">Here FIRSTROW is specified because it will skip the header from the rowdata(Otherwise it will show error)</div>
<div id="_mcePaste">In certain cases LASTROW may be included if the last row of rawdata damaged.we can add IDENTITY or other constraint</div>
<div id="_mcePaste">like Default can be added to the table</div>
<div id="_mcePaste">eg scripts</div>
<div></div>
<div id="_mcePaste">&#8212;&#8212;Adding Identity&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</div>
<div id="_mcePaste">ALTER TABLE tbl</div>
<div id="_mcePaste">ADD tbl_ID bigint IDENTITY(1,1) NOT NULl</div>
<div></div>
<div id="_mcePaste">&#8212;&#8212;Adding Defaults&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</div>
<div id="_mcePaste">ALTER TABLE tbl</div>
<div id="_mcePaste">ADD RS_STATUS CHAR(1)</div>
<div id="_mcePaste">CONSTRAINT DF_tbl_Status DEFAULT &#8216;Y&#8217; NOT NULL</div>
<div></div>
<div id="_mcePaste">ALTER TABLE tbl</div>
<div id="_mcePaste">ADD RS_PROCESS_DATE DATETIME</div>
<div id="_mcePaste">CONSTRAINT DF_CDR_PROCESS_DATE DEFAULT GETDATE() NOT NULL</div>
<div></div>
<div id="_mcePaste">&#8212;&#8212;-Adding Primary Key&#8212;&#8212;&#8212;&#8212;&#8212;-</div>
<div id="_mcePaste">ALTER TABLE tbl</div>
<div id="_mcePaste">ADD CONSTRAINT CUS_KEY PRIMARY KEY(tbl_ID)</div>
<div></div>
<div id="_mcePaste">After this process we will get the complete table.But we want to arrange the columns and column space</div>
<div id="_mcePaste">3.Creation of actual table</div>
<div id="_mcePaste">Creation of actual table include the process of creating the required table.</div>
<div id="_mcePaste">the columns should be arranged in the required order and column space should be managed.</div>
<div id="_mcePaste">4.Transfering data from Temperory table to Actual table</div>
<div id="_mcePaste">Now we can transfer data from the Dummy table to actual table.</div>
<div id="_mcePaste">eg.</div>
<div id="_mcePaste">INSERT INTO</div>
<div id="_mcePaste">(</div>
<div id="_mcePaste">COL1,COL2&#8230;&#8230;.</div>
<div id="_mcePaste">)</div>
<div id="_mcePaste">SELECT</div>
<div id="_mcePaste">COL1,COL2&#8230;&#8230;.</div>
<div id="_mcePaste">FROM DUMMY_TABLE</div>
<div id="_mcePaste">5.Droping of all temperory objects</div>
<div id="_mcePaste">After tranfering all data to the actual table we can drop the Dummy table</div>
<p>Bulkinsert process<br />
Introduction<br />
Usually if we want to Tranfer a text file into a DB table,There are two ways<br />
1.Using SSIS2.Using SQL<br />
1.Using SSIS<br />
We can use BulkInsert Task or Simple Dataflow task for this process.<br />
2.Using SQL<br />
We can use bcp,Openrowset or Bulkinsert<br />
Scope of this document explains the use of Bulkinsert command.<br />
Usually we prefer Bulkinsert because it is Faster and we can include many functions while Dataloading<br />
The various steps included in the Dataloading are<br />
1.Creation of Temperory or dummy table<br />
2.Data loading to the Temperory table<br />
3.Creation of actual table<br />
4.Transfering data from Temperory table to Actual table<br />
5.Droping of all temperory objects</p>
<p>1.Creation of Temperory or dummy table<br />
This process includes the creation of Temperory table.Here temperory table means the actual physical table.It is not advisable to use #table if we are loading Huge data.While using the Bulkinsert task we have to remove all Identity columnor default column if it is not available in the row data.And it is advisable to give large values(eg. varchar(1000)  for the first and last columns because there may be unusable vacant space at the end of each row.<br />
2.Data loading to the Temperory table<br />
Once temperory table is created we can load the data in to the Temperory table.We can have look on the Source data beforeloading(If the data is more than 1 GB i recomend Jujuedit to view the content)In normal case we use direct script to load the data<br />
ie for eg.&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
BULK INSERT TEST_TABLEFROM ‘Test_data.txt’WITH(FIELDTERMINATOR =’,&#8217;,ROWTERMINATOR = ‘\n’)&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
This is the script we use in Ideal situations like..If the row data dont have any header. or the row data generated not by a unix machine where ROWTERMINATOR is not ‘\n’.FIELDTERMINATOR is nothing but the character used to seperate each fields in the given examle its a comma.ROWTERMINATOR is nothing but the entity which seperates each row in ideal case it will be newline character ‘\n’we can enforce identity ,Unique constraint,primary key constraint or NOT NULL constraint by including KEEPIDENTITYor CHECK_CONSTRAINT inside the bracket.<br />
But we may not be lucky in all the cases.If the data is generated by a Unix based machine then the ideal query willnot work.So we have to use a special dynamic query<br />
ie for eg.&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;declare @sql nvarchar(4000)set @sql =‘BULK INSERT Dest_tableFROM ”\\Loc ”WITH(FIRSTROW = 2,FIELDTERMINATOR = ”|”,ROWTERMINATOR = ”’ + nchar(10) + ”’ ,LASTROW=3355072)’select @sqlexec(@sql)&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Here FIRSTROW is specified because it will skip the header from the rowdata(Otherwise it will show error)In certain cases LASTROW may be included if the last row of rawdata damaged.we can add IDENTITY or other constraintlike Default can be added to the table<br />
eg scripts &#8212;&#8212;Adding Identity&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;ALTER TABLE tblADD tbl_ID bigint IDENTITY(1,1) NOT NULl<br />
&#8212;&#8212;Adding Defaults&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-ALTER TABLE tblADD RS_STATUS CHAR(1)CONSTRAINT DF_tbl_Status DEFAULT &#8216;Y&#8217; NOT NULL<br />
ALTER TABLE tblADD RS_PROCESS_DATE DATETIMECONSTRAINT DF_CDR_PROCESS_DATE DEFAULT GETDATE() NOT NULL<br />
&#8212;&#8212;-Adding Primary Key&#8212;&#8212;&#8212;&#8212;&#8212;-ALTER TABLE tblADD CONSTRAINT CUS_KEY PRIMARY KEY(tbl_ID)<br />
After this process we will get the complete table.But we want to arrange the columns and column space<br />
3.Creation of actual table<br />
Creation of actual table include the process of creating the required table.the columns should be arranged in the required order and column space should be managed.<br />
4.Transfering data from Temperory table to Actual table<br />
Now we can transfer data from the Dummy table to actual table.<br />
eg.<br />
INSERT INTO (COL1,COL2&#8230;&#8230;.)SELECTCOL1,COL2&#8230;&#8230;.FROM DUMMY_TABLE<br />
5.Droping of all temperory objects<br />
After tranfering all data to the actual table we can drop the Dummy table</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=72&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2010/04/12/bulkinsert-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Use of Switchoffset Function in SQL Server</title>
		<link>http://sinshith.wordpress.com/2009/11/06/use-of-switchoffset-function-in-sql-server/</link>
		<comments>http://sinshith.wordpress.com/2009/11/06/use-of-switchoffset-function-in-sql-server/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 15:09:44 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=66</guid>
		<description><![CDATA[&#160; &#8211;Creating a test table CREATE TABLE TB ( FG DATETIME ) &#8211;Insert an element INSERT TB SELECT GETDATE() SELECT * FROM TB &#8211;convert in to Indian offset time(means +5.30) SELECT TODATETIMEOFFSET(FG,&#8217;+05:30&#8242;) DATETIME_OFFSET INTO #TEMP FROM TB SELECT * FROM #TEMP &#8211;Convert in to Eastern US Time using Switchoffset SELECT SWITCHOFFSET(DATETIME_OFFSET,&#8217;-04:00&#8242;) EASTERN_TIME_US FROM #TEMP &#8211;Creating [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=66&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<div id="_mcePaste">&#8211;Creating a test table</div>
<div id="_mcePaste">CREATE TABLE TB</div>
<div id="_mcePaste">(</div>
<div id="_mcePaste">FG DATETIME</div>
<div id="_mcePaste">)</div>
<div id="_mcePaste">&#8211;Insert an element</div>
<div id="_mcePaste">INSERT TB</div>
<div id="_mcePaste">SELECT GETDATE()</div>
<div id="_mcePaste">SELECT * FROM TB</div>
<div id="_mcePaste">&#8211;convert in to Indian offset time(means +5.30)</div>
<div id="_mcePaste">SELECT TODATETIMEOFFSET(FG,&#8217;+05:30&#8242;) DATETIME_OFFSET INTO #TEMP</div>
<div id="_mcePaste">FROM TB</div>
<div id="_mcePaste">SELECT * FROM #TEMP</div>
<div id="_mcePaste">&#8211;Convert in to Eastern US Time using Switchoffset</div>
<div id="_mcePaste">SELECT SWITCHOFFSET(DATETIME_OFFSET,&#8217;-04:00&#8242;) EASTERN_TIME_US FROM #TEMP</div>
<p>&#8211;Creating a test table<br />
CREATE TABLE TB(FG DATETIME)&#8211;Insert an elementINSERT TBSELECT GETDATE()<br />
SELECT * FROM TB&#8211;convert in to Indian offset time(means +5.30)SELECT TODATETIMEOFFSET(FG,&#8217;+05:30&#8242;) DATETIME_OFFSET INTO #TEMPFROM TB<br />
SELECT * FROM #TEMP&#8211;Convert in to Eastern US Time using SwitchoffsetSELECT SWITCHOFFSET(DATETIME_OFFSET,&#8217;-04:00&#8242;) EASTERN_TIME_US FROM #TEMP</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=66&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/11/06/use-of-switchoffset-function-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple but Useful</title>
		<link>http://sinshith.wordpress.com/2009/10/26/simple-but-useful/</link>
		<comments>http://sinshith.wordpress.com/2009/10/26/simple-but-useful/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 06:42:05 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=63</guid>
		<description><![CDATA[/*SIMPLE BUT USEFUL*/ /*CREATING TABLE A1*/ CREATE TABLE A1 (CL1 CHAR) &#8211;DROP TABLE A1 /*INSERTING ELEMENTS TO A1*/ INSERT INTO A1 SELECT &#8216;A&#8217; UNION ALL SELECT &#8216;B&#8217; UNION ALL SELECT &#8216;C&#8217; UNION ALL SELECT &#8216;D&#8217; UNION ALL SELECT &#8216;E&#8217; /*CREATING TABLE A2*/ CREATE TABLE A2 (CL1 CHAR) &#8211;DROP TABLE A2 /*INSERTING ELEMENTS TO A2*/ INSERT [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=63&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*SIMPLE BUT USEFUL*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*CREATING TABLE A1*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">CREATE TABLE A1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(CL1 CHAR)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;DROP TABLE A1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*INSERTING ELEMENTS TO A1*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">INSERT INTO A1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;A&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;B&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;C&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;D&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;E&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*CREATING TABLE A2*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">CREATE TABLE A2</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(CL1 CHAR)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;DROP TABLE A2</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*INSERTING ELEMENTS TO A2*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">INSERT INTO A2</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;K&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;L&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;C&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;D&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">UNION ALL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT &#8216;E&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*GETTING ALL ELEMENTS OF A1 WITH CORRESPONDING MATCH IN A2*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT * FROM A1 A</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">LEFT OUTER JOIN A2 B</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">ON(A.CL1=B.CL1)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*GETTING ELEMENTS ONLY IN A1 TABLE */</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT * FROM A1 A</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">LEFT OUTER JOIN A2 B</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">ON(A.CL1=B.CL1)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">WHERE B.CL1 IS NULL</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*SQL SERVER 2008 SHORTCUT&#8230;USAGE OF EXCEPT*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT * FROM A1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">EXCEPT</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT * FROM A2</div>
<p>/*SIMPLE BUT USEFUL*/</p>
<p>/*CREATING TABLE A1*/</p>
<p>CREATE TABLE A1</p>
<p>(CL1 CHAR)</p>
<p>&#8211;DROP TABLE A1</p>
<p>/*INSERTING ELEMENTS TO A1*/</p>
<p>INSERT INTO A1</p>
<p>SELECT &#8216;A&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;B&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;C&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;D&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;E&#8217;</p>
<p>/*CREATING TABLE A2*/</p>
<p>CREATE TABLE A2</p>
<p>(CL1 CHAR)</p>
<p>&#8211;DROP TABLE A2</p>
<p>/*INSERTING ELEMENTS TO A2*/</p>
<p>INSERT INTO A2</p>
<p>SELECT &#8216;K&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;L&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;C&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;D&#8217;</p>
<p>UNION ALL</p>
<p>SELECT &#8216;E&#8217;</p>
<p>/*GETTING ALL ELEMENTS OF A1 WITH CORRESPONDING MATCH IN A2*/</p>
<p>SELECT * FROM A1 A</p>
<p>LEFT OUTER JOIN A2 B</p>
<p>ON(A.CL1=B.CL1)</p>
<p>/*GETTING ELEMENTS ONLY IN A1 TABLE */</p>
<p>SELECT * FROM A1 A</p>
<p>LEFT OUTER JOIN A2 B</p>
<p>ON(A.CL1=B.CL1)</p>
<p>WHERE B.CL1 IS NULL</p>
<p>/*SQL SERVER 2008 SHORTCUT&#8230;USAGE OF EXCEPT*/</p>
<p>SELECT * FROM A1</p>
<p>EXCEPT</p>
<p>SELECT * FROM A2</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=63&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/10/26/simple-but-useful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>BULK INSERT</title>
		<link>http://sinshith.wordpress.com/2009/07/03/bulk-insert/</link>
		<comments>http://sinshith.wordpress.com/2009/07/03/bulk-insert/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 10:29:48 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=57</guid>
		<description><![CDATA[BULK INSERT TEST_TABLE FROM &#8216;Test_data.txt&#8217; WITH ( FIELDTERMINATOR =&#8217;,', ROWTERMINATOR = &#8216;\n&#8217; ) Bulk Insert is a method of inserting Text data or Row data in to Sql table directly. For inserting that we need to specify the Destination table(Here TEST_TABLE) Source data(Here Test_data.txt), FIELDTERMINATOR(For inserting to each particular element to respective columns) and ROWTERMINATOR(For [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=57&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>BULK INSERT TEST_TABLE</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>FROM &#8216;Test_data.txt&#8217;</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>WITH</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>(</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>FIELDTERMINATOR =&#8217;,',</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>ROWTERMINATOR = &#8216;\n&#8217;</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>)</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>Bulk Insert is a method of inserting Text data or Row data in to Sql table directly.</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>For inserting that we need to specify the Destination table(Here TEST_TABLE)</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>Source data(Here Test_data.txt), FIELDTERMINATOR(For inserting to each particular element to respective columns) and</strong></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;"><strong>ROWTERMINATOR(For terminating each Row).</strong></div>
<div><strong>BULK INSERT</strong></div>
<div>BULK INSERT TEST_TABLE</div>
<div>FROM &#8216;Test_data.txt&#8217;</div>
<div>WITH</div>
<div>(</div>
<div>FIELDTERMINATOR =&#8217;,',</div>
<div>ROWTERMINATOR = &#8216;\n&#8217;</div>
<div>)</div>
<div>Bulk Insert is a method of inserting Text data or Raw data in to Sql table directly.</div>
<div>For inserting that we need to specify the Destination table(Here TEST_TABLE)</div>
<div>Source data(Here Test_data.txt), FIELDTERMINATOR(For inserting to each particular element to respective columns) and</div>
<div>ROWTERMINATOR(For terminating each Row).</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=57&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/07/03/bulk-insert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Use of OUTPUT &#8230;.</title>
		<link>http://sinshith.wordpress.com/2009/07/02/use-of-output/</link>
		<comments>http://sinshith.wordpress.com/2009/07/02/use-of-output/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 08:44:28 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=53</guid>
		<description><![CDATA[/*Create one SP for multiplicating two values.And passed the result into the variable @v2*/ CREATE PROCEDURE SP_REF &#8211;DECLARE @V1 VARCHAR(50) @V2 BIGINT OUTPUT AS SELECT @V2=@V2*@V2 RETURN &#8211;drop procedure SP_REF /*Passed the result of the variable in to @v1 and executed.*/ DECLARE @V1 VARCHAR(50) SELECT @V1=10000 EXEC SP_REF @V1 OUTPUT PRINT &#8216;RESULT:&#8217;+@V1 /*Create one SP [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=53&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*Create one SP for multiplicating two values.And passed the result into the variable @v2*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">CREATE PROCEDURE SP_REF</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;DECLARE @V1 VARCHAR(50)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">@V2 BIGINT OUTPUT</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">AS</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT @V2=@V2*@V2</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">RETURN</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;drop procedure SP_REF</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*Passed the result of the variable in to @v1 and executed.*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @V1 VARCHAR(50)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT @V1=10000</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">EXEC SP_REF @V1 OUTPUT</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">PRINT &#8216;RESULT:&#8217;+@V1</div>
<div>/*Create one SP for multiplicating two values.And passed the result into the variable @v2*/</div>
<div></div>
<div>CREATE PROCEDURE SP_REF</div>
<div>&#8211;DECLARE @V1 VARCHAR(50)</div>
<div>@V2 BIGINT OUTPUT</div>
<div>AS</div>
<div>SELECT @V2=@V2*@V2</div>
<div>RETURN</div>
<div></div>
<div>&#8211;drop procedure SP_REF</div>
<div></div>
<div>/*Passed the result of the variable in to @v1 and executed.*/</div>
<div></div>
<div>DECLARE @V1 VARCHAR(50)</div>
<div>SELECT @V1=10000</div>
<div>EXEC SP_REF @V1 OUTPUT</div>
<div>PRINT &#8216;RESULT:&#8217;+@V1</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=53&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/07/02/use-of-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Some useful functions</title>
		<link>http://sinshith.wordpress.com/2009/07/02/some-useful-functions/</link>
		<comments>http://sinshith.wordpress.com/2009/07/02/some-useful-functions/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 07:15:14 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[SQL Basics]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=45</guid>
		<description><![CDATA[SELECT UPPER (&#8216;this is good&#8217;) SELECT DATEADD(DAY,1,GETDATE()) SELECT MONTH(GETDATE()) SELECT CEILING(10.50) SELECT FLOOR(10.50) SELECT POWER(3,3) SELECT ROUND(10.3522,1) SELECT DATEADD(DAY, 21, GETDATE())AS TIMEFRAME SELECT DATEADD(YEAR,1,GETDATE()) SELECT DATEDIFF(DAY,&#8217;2009-05-12&#8242;,GETDATE()) SELECT DATENAME(YEAR,GETDATE()) AS NAME SELECT DATEPART(MONTH,GETDATE()) SELECT GETUTCDATE() SELECT GETDATE() SELECT DAY(GETDATE()) SELECT ASCII(&#8216;`&#8217;) SELECT NCHAR(&#8217;5&#8242;) SELECT SOUNDEX(&#8216;SINSHITH&#8217;),SOUNDEX(&#8216;KKITH&#8217;) SELECT CHAR(&#8217;97&#8242;) DECLARE @V1 VARCHAR(50) SET @V1=&#8217;VSFASFASFASDFEFWEVSDSS&#8217; SELECT PATINDEX(&#8216;v%&#8217;,@V1) DECLARE @DOC [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=45&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT UPPER (&#8216;this is good&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DATEADD(DAY,1,GETDATE())</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT MONTH(GETDATE())</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT CEILING(10.50)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT FLOOR(10.50)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT POWER(3,3)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT ROUND(10.3522,1)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DATEADD(DAY, 21, GETDATE())AS TIMEFRAME</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DATEADD(YEAR,1,GETDATE())</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DATEDIFF(DAY,&#8217;2009-05-12&#8242;,GETDATE())</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DATENAME(YEAR,GETDATE()) AS NAME</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DATEPART(MONTH,GETDATE())</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT GETUTCDATE()</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT GETDATE()</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT DAY(GETDATE())</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT ASCII(&#8216;`&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT NCHAR(&#8217;5&#8242;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT SOUNDEX(&#8216;SINSHITH&#8217;),SOUNDEX(&#8216;KKITH&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT CHAR(&#8217;97&#8242;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @V1 VARCHAR(50)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SET @V1=&#8217;VSFASFASFASDFEFWEVSDSS&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT PATINDEX(&#8216;v%&#8217;,@V1)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @DOC VARCHAR(64)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SET @DOC=&#8217;GER REGHREHEGERH GHERGERGERE&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT CHARINDEX(&#8216;RH&#8217;,@DOC)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT REPLACE(&#8216;HTRHTHTHT&#8217;,'THT&#8217;,'MMM&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT STUFF(&#8216;ABCDEFG&#8217;,2,3,&#8217;HIJKLMNO&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT REPLICATE(&#8216;ABC&#8217;,8)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT SUBSTRING(&#8216;ABCDEFGH&#8217;,2,3) AS X</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT REVERSE(&#8216;abc&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT LTRIM(&#8216;   abc&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT RTRIM(&#8216;abc    &#8217;)</div>
<div>/*Some useful functions&#8230;No explanations..You have to try it out and ask me if any doubts*/</div>
<div>
<ul>
<li>SELECT UPPER (&#8216;this is good&#8217;)</li>
<li>SELECT DATEADD(DAY,1,GETDATE())</li>
<li>SELECT MONTH(GETDATE())</li>
<li>SELECT CEILING(10.50)</li>
<li>SELECT FLOOR(10.50)</li>
<li>SELECT POWER(3,3)</li>
<li>SELECT ROUND(10.3522,1)</li>
<li>SELECT DATEADD(DAY, 21, GETDATE())AS TIMEFRAME</li>
<li>SELECT DATEADD(YEAR,1,GETDATE())</li>
<li>SELECT DATEDIFF(DAY,&#8217;2009-05-12&#8242;,GETDATE())</li>
<li>SELECT DATENAME(YEAR,GETDATE()) AS NAME</li>
<li>SELECT DATEPART(MONTH,GETDATE())</li>
<li>SELECT GETUTCDATE()</li>
<li>SELECT GETDATE()</li>
<li>SELECT DAY(GETDATE())</li>
<li>SELECT ASCII(&#8216;`&#8217;)</li>
<li>SELECT NCHAR(&#8217;5&#8242;)</li>
<li>SELECT SOUNDEX(&#8216;SINSHITH&#8217;),SOUNDEX(&#8216;KKITH&#8217;)</li>
<li>SELECT CHAR(&#8217;97&#8242;)</li>
</ul>
<ul>
<li>SELECT REPLACE(&#8216;HTRHTHTHT&#8217;,'THT&#8217;,'MMM&#8217;)</li>
<li>SELECT STUFF(&#8216;ABCDEFG&#8217;,2,3,&#8217;HIJKLMNO&#8217;)</li>
<li>SELECT REPLICATE(&#8216;ABC&#8217;,8)</li>
<li>SELECT SUBSTRING(&#8216;ABCDEFGH&#8217;,2,3) AS X</li>
<li>SELECT REVERSE(&#8216;abc&#8217;)</li>
<li>SELECT LTRIM(&#8216;   abc&#8217;)</li>
<li>SELECT RTRIM(&#8216;abc    &#8217;)</li>
</ul>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=45&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/07/02/some-useful-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Enabling and disabling DML Triggers</title>
		<link>http://sinshith.wordpress.com/2009/07/02/enabling-and-disabling-dml-triggers/</link>
		<comments>http://sinshith.wordpress.com/2009/07/02/enabling-and-disabling-dml-triggers/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 07:10:32 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/?p=43</guid>
		<description><![CDATA[/*PROGRAM TO DISABLE ALL TRIGGER IN A TABLE WITHOUT USING CURSOR*/ CREATE PROCEDURE TEST8 ( @TABLE_NAME VARCHAR(100) ) AS DECLARE @V1 VARCHAR(100) SET @V1=&#8217;ALTER TABLE &#8216; + @TABLE_NAME +&#8217; DISABLE TRIGGER ALL&#8217; EXEC(@V1) &#8211;PRINT(@V1) &#8211;EXEC TEST8 &#8216;TEST&#8217; /*PROGRAM TO ENABLE ALL TRIGGER IN A TABLE WITHOUT USING CURSOR*/ CREATE PROCEDURE TEST9 ( @TABLE_NAME VARCHAR(100) ) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=43&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*PROGRAM TO DISABLE ALL TRIGGER IN A TABLE WITHOUT USING CURSOR*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">CREATE PROCEDURE TEST8</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">@TABLE_NAME VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">AS</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @V1 VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SET @V1=&#8217;ALTER TABLE &#8216; + @TABLE_NAME +&#8217; DISABLE TRIGGER ALL&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">EXEC(@V1)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;PRINT(@V1)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;EXEC TEST8 &#8216;TEST&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">/*PROGRAM TO ENABLE ALL TRIGGER IN A TABLE WITHOUT USING CURSOR*/</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">CREATE PROCEDURE TEST9</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">@TABLE_NAME VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">AS</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @V1 VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SET @V1=&#8217;ALTER TABLE &#8216;+@TABLE_NAME +&#8217; ENABLE TRIGGER ALL&#8217;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">EXEC(@V1)</div>
<div>/*PROGRAM TO DISABLE ALL TRIGGER IN A TABLE WITHOUT USING CURSOR*/</div>
<div>CREATE PROCEDURE TEST8</div>
<div>(</div>
<div>@TABLE_NAME VARCHAR(100)</div>
<div>)</div>
<div>AS</div>
<div>DECLARE @V1 VARCHAR(100)</div>
<div>SET @V1=&#8217;ALTER TABLE &#8216; + @TABLE_NAME +&#8217; DISABLE TRIGGER ALL&#8217;</div>
<div>EXEC(@V1)</div>
<div>&#8211;PRINT(@V1)</div>
<div></div>
<div>&#8211;EXEC TEST8 &#8216;TEST&#8217;</div>
<div></div>
<div>/*PROGRAM TO ENABLE ALL TRIGGER IN A TABLE WITHOUT USING CURSOR*/</div>
<div>CREATE PROCEDURE TEST9</div>
<div>(</div>
<div>@TABLE_NAME VARCHAR(100)</div>
<div>)</div>
<div>AS</div>
<div>DECLARE @V1 VARCHAR(100)</div>
<div>SET @V1=&#8217;ALTER TABLE &#8216;+@TABLE_NAME +&#8217; ENABLE TRIGGER ALL&#8217;</div>
<div>EXEC(@V1)</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=43&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/07/02/enabling-and-disabling-dml-triggers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
		<item>
		<title>Procedure for droping all constraints from a table</title>
		<link>http://sinshith.wordpress.com/2009/06/26/procedure-for-droping-all-constraints-from-a-table/</link>
		<comments>http://sinshith.wordpress.com/2009/06/26/procedure-for-droping-all-constraints-from-a-table/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 13:18:27 +0000</pubDate>
		<dc:creator>sinshith</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sinshith.wordpress.com/2009/06/26/procedure-for-droping-all-constraints-from-a-table/</guid>
		<description><![CDATA[CREATE PROCEDURE TEST10 ( @TABLE_NAME VARCHAR(100) ) AS DECLARE @V1 VARCHAR(100) DECLARE @V2 VARCHAR(100) DECLARE CUR2 CURSOR FOR SELECT NAME FROM SYSOBJECTS WHERE XTYPE IN (&#8216;C&#8217;,'D&#8217;,'F&#8217;,'PK&#8217;,'UQ&#8217;) AND OBJECT_NAME(PARENT_OBJ) = @TABLE_NAME OPEN CUR2 FETCH NEXT FROM CUR2 INTO @V1 WHILE(@@FETCH_STATUS=0) BEGIN SET @V2=&#8217;ALTER TABLE &#8216;+@TABLE_NAME+&#8217; DROP CONSTRAINT &#8216;+@V1 &#8211;PRINT(@V2) EXEC(@V2) FETCH NEXT FROM CUR2 INTO @V1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=36&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">
<p>CREATE PROCEDURE TEST10</p></div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">(</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">@TABLE_NAME VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">AS</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @V1 VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE @V2 VARCHAR(100)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DECLARE CUR2 CURSOR FOR</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SELECT</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">NAME</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">FROM</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SYSOBJECTS</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">WHERE</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">XTYPE IN (&#8216;C&#8217;,'D&#8217;,'F&#8217;,'PK&#8217;,'UQ&#8217;)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">AND</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">OBJECT_NAME(PARENT_OBJ) = @TABLE_NAME</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">OPEN CUR2</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">FETCH NEXT FROM CUR2 INTO @V1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">WHILE(@@FETCH_STATUS=0)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">BEGIN</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">SET @V2=&#8217;ALTER TABLE &#8216;+@TABLE_NAME+&#8217; DROP CONSTRAINT &#8216;+@V1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&#8211;PRINT(@V2)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">EXEC(@V2)</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">FETCH NEXT FROM CUR2 INTO @V1</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">END</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">CLOSE CUR2</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">DEALLOCATE CUR2</div>
<p>CREATE PROCEDURE TEST10</p>
<p>(</p>
<p>@TABLE_NAME VARCHAR(100)</p>
<p>)</p>
<p>AS</p>
<p>DECLARE @V1 VARCHAR(100)</p>
<p>DECLARE @V2 VARCHAR(100)</p>
<p>DECLARE CUR2 CURSOR FOR</p>
<p>SELECT</p>
<p>NAME</p>
<p>FROM</p>
<p>SYSOBJECTS</p>
<p>WHERE</p>
<p>XTYPE IN (&#8216;C&#8217;,'D&#8217;,'F&#8217;,'PK&#8217;,'UQ&#8217;)</p>
<p>AND</p>
<p>OBJECT_NAME(PARENT_OBJ) = @TABLE_NAME</p>
<p>OPEN CUR2</p>
<p>FETCH NEXT FROM CUR2 INTO @V1</p>
<p>WHILE(@@FETCH_STATUS=0)</p>
<p>BEGIN</p>
<p>SET @V2=&#8217;ALTER TABLE &#8216;+@TABLE_NAME+&#8217; DROP CONSTRAINT &#8216;+@V1</p>
<p>&#8211;PRINT(@V2)</p>
<p>EXEC(@V2)</p>
<p>FETCH NEXT FROM CUR2 INTO @V1</p>
<p>END</p>
<p>CLOSE CUR2</p>
<p>DEALLOCATE CUR2</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sinshith.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sinshith.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sinshith.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sinshith.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sinshith.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sinshith.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sinshith.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sinshith.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sinshith.wordpress.com&amp;blog=7653567&amp;post=36&amp;subd=sinshith&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://sinshith.wordpress.com/2009/06/26/procedure-for-droping-all-constraints-from-a-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d2f54a8a1e6cacdb1872205f1c880419?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinshith</media:title>
		</media:content>
	</item>
	</channel>
</rss>
