Geeks With Blogs
Nouman Zakir while (true) { Post.NewArticle(); } SQL
Using SELECT statement to UPDATE records in SQL
You can use SELECT statement to update records through UPDATE statement. In the SET Clause use the SELECT statement along with desired filters to update the records. UPDATE tblDestination SET tblDestination.col=value WHERE EXISTS ( SELECT col2.value FROM tblSource WHERE tblSource.join_col=tblDesti... AND tblSource.constraint=value) ......

Posted On Tuesday, August 4, 2009 6:28 AM

Using SELECT statement to INSERT records in SQL
In INSERT statement, by replacing the VALUES clause with a SELECT statement you can get a set of records for INSERT. Suppose I have a table called table_A and I want to populate it with the ID, Name and Address of table_B. The statement would look something like this: INSERT table_A (col_id, col_name, col_address) SELECT col_id, col_name, col_address FROM table_B WHERE col_city = 'karachi' This will take the records with col_city='karachi' and load them into the table table_A. I can use any type ......

Posted On Tuesday, August 4, 2009 4:57 AM

Optional parameters in SQL Stored Procedures
You can add optional parameters in stored procedures by setting a default value for each parameter that you want to make optional. The default value is typically NULL, but it's not necessary. Example: CREATE PROCEDURE dbo.mySP @firstParam VARCHAR(32) = NULL, @secondParam INT = NULL AS BEGIN SET NOCOUNT ON SELECT * FROM [TableName] WHERE Param1 = @firstParam AND Param2 = @secondParam END GO -- EXEC dbo.mySP @firstParam ='bar', @secondParam =4 EXEC dbo.mySP @firstParam ='bar' EXEC dbo.mySP @secondParam ......

Posted On Saturday, February 28, 2009 5:48 AM

Reset table identity (reseed) in SQL Server with DBCC RESEED
You may use DBCC CHECKIDENT to reseed (reset) the identity column of any table in SQL Server. Example: A table has 10 rows with 10 as last identity. The next record will automatically genrate 11, to start the new identity use the follwing T SQL query in query analyzer. DBCC CHECKIDENT (tableName, reseed, 15) To set the seed to zero use the following T SQL query in query analyzer. DBCC CHECKIDENT (tableName, reseed, 0) Avoid using a value lower than the current value, doing this will violate the uniqueness ......

Posted On Wednesday, February 11, 2009 3:59 AM

Find text in SQL stored procedures

Method to retrieve every text inside the stored procedures of a database

SELECT B.Name, *
FROM syscomments A INNER JOIN sysobjects B
ON A.id = B.id
WHERE A.text like '%tblNames%'

Posted On Monday, February 2, 2009 12:43 AM

Copyright © Nouman Zakir | Powered by: GeeksWithBlogs.net