DECLARE @procedureName varchar(500)
DECLARE cur CURSOR
FOR SELECT [name] FROM sys.procedures WHERE type in ('p', 'fn') and is_ms_shipped=0 and name not like 'sp[_]%diagram%'
OPEN cur
FETCH NEXT FROM cur INTO @procedureName
WHILE @@fetch_status = 0
BEGIN
EXEC('DROP PROCEDURE ' + @procedureName)
--select @procedureName
FETCH NEXT FROM cur INTO @procedureName
END
CLOSE cur
DEALLOCATE cur
How to write code in C#, Asp.Net, Php, Javascript, C. On this blog you will find example codes that will help you to understand concepts of programming.
Thursday, June 7, 2012
How to delete procedures, user functions or views from a database in SQL?
In order to delete all functions, procedures or views from a database you can help yourself by using this query:
How to get list with procedures, functions or views in Sql?
In order to obtain a list with procedures(P), functions(FN) or views(V) in Sql you can run this query:
SELECT [name], [type], create_date, modify_date
FROM sys.objects
WHERE [type] in ('P', 'FN', 'V')
order by [Type ] asc
Tuesday, May 15, 2012
How to convert string to string[] in C#?
It might happen that you receive from POST a variable name that is in fact an array. So in this case you should convert your object into string[]. How do you do that?
Well, as usually, it is simple:
string[] RoomOptions = new string[] { Request["room_options"] };
So there you are.
This was for solving asp error message saying:
Error message: Cannot convert type 'string' to 'string[]'
Well, as usually, it is simple:
string[] RoomOptions = new string[] { Request["room_options"] };
So there you are.
This was for solving asp error message saying:
Error message: Cannot convert type 'string' to 'string[]'
Friday, May 11, 2012
How to make an update query using join in SQL
Today it helped me a lot this page which instructed me how to make an update query using join.
So you can go and check it out on
http://www.bennadel.com/blog/938-Using-A-SQL-JOIN-In-A-SQL-UPDATE-Statement-Thanks-John-Eric-.htm
Here you can see how I wrote my update command:
UPDATE O
set O.Payed = Payed - 1, O.PaymentDate = null , refPaymentMethodId = null
from [Orders] O
join PaymentMethod pm on pm.PaymentMethodID = O.refPaymentMethodID
where OrderID = @OrderID and pm.GenerateReceipt = 1;
Cheers.
Here you can see how I wrote my update command:
UPDATE O
set O.Payed = Payed - 1, O.PaymentDate = null , refPaymentMethodId = null
from [Orders] O
join PaymentMethod pm on pm.PaymentMethodID = O.refPaymentMethodID
where OrderID = @OrderID and pm.GenerateReceipt = 1;
Cheers.
Thursday, April 12, 2012
How to use conditional operator(?:) in c# in a string?
The conditional operator (?:) returns one of two values depending on the value of a Boolean expression.
So, don't hesitate to use conditional operator whenever you are in need of it.
Have a nice day.
The condition must evaluate to true or false. If condition is true, first_expression is evaluated and becomes the result. If condition is false, second_expression is evaluated and becomes the result. Only one of the two expressions is evaluated.
Either the type of first_expression and second_expression must be the same, or an implicit conversion must exist from one type to the other.
This is what MSDN says. :)
Now: it might help you to know how to use conditional operator when generate a string. I will give you a simple method which receives a input parameter and according to that will generate a link.
public string GenerateLink(string Option)
{
string Response = "";
Response = "<a href=\"YourPage.aspx?option=" + ((Option == "holiday") ? "goHoliday" : "goAndWork").ToString() + "\">Click</a>";
return Response;
}
So, don't hesitate to use conditional operator whenever you are in need of it.
Have a nice day.
Friday, April 6, 2012
How to verify if two strings are equal in Sql?
This question might appear to you when you want to verify credentials for a user at login.
I found out that for SQL these two conditions will give the same result.
1. if(@Password = 'test')
or
2. if(@Password = 'test ')
(note the space)
So there is a problem.
I found out a simple solution for comparing these two strings. When you compare strings you have to hash them. So we are going to use Hashbytes function. Here you can find more details.
For our example we can verify like this:
if ( HASHBYTES('MD5', convert(nvarchar(50), @Password )) = HASHBYTES('MD5', 'test ' ))
will return expected result.
One think to note: it is important to keep in mind datatype. Datatypes must be the same otherwise you won't get the same hash. Md5 has in mind even data types when converting ;)
Hope will help you.
I found out that for SQL these two conditions will give the same result.
1. if(@Password = 'test')
or
2. if(@Password = 'test ')
(note the space)
So there is a problem.
I found out a simple solution for comparing these two strings. When you compare strings you have to hash them. So we are going to use Hashbytes function. Here you can find more details.
For our example we can verify like this:
if ( HASHBYTES('MD5', convert(nvarchar(50), @Password )) = HASHBYTES('MD5', 'test ' ))
will return expected result.
One think to note: it is important to keep in mind datatype. Datatypes must be the same otherwise you won't get the same hash. Md5 has in mind even data types when converting ;)
Hope will help you.
Friday, March 9, 2012
How To Allow Blocked Content on Internet Explorer
I thought that will be great if I will post here on this blog for anytime when I found an article on the internet that helped me. So based on this idea I am going to give you a short description of problem(found in title, maybe) and the link to the solution.
So one of my question of today was: How To Allow Blocked Content on Internet Explorer?
Instructions found you can get at http://www.genopro.com/help/report-generator/allow-blocked-content/
Regards
So one of my question of today was: How To Allow Blocked Content on Internet Explorer?
Instructions found you can get at http://www.genopro.com/help/report-generator/allow-blocked-content/
Regards
Subscribe to:
Posts (Atom)