RSS

Monthly Archives: July 2012

Passing column name as argument to procedure in SQL

By the following way you can pass the column name as a parameter/argument to the procedure in SQL.

create proc PROCEDURENAME

as

begin

declare @CoumnName varchar(30),@Query varchar(100);

set @ColumnName=’ColumnName’;

set @Query=’select FoodName,ImageUrl,Price from tblFood where ‘+@ColumnName+’=condition’

exec sp_executesql @Query

end

 
Leave a comment

Posted by on July 23, 2012 in SQL

 

Read only Database

To make a database as read only,

ALTER DATABASE [Database name] SET READ_ONLY

To remove read only property of database,

ALTER DATABASE [Database name] SET READ_WRITE

 
Leave a comment

Posted by on July 23, 2012 in SQL