Tuesday, 21 April 2020

select distinct Value when using left join and order by on two tables

You can use aggregate functions in ORDER BY:

SELECT shops.id AS shopid -- No need to use MAX(...) here
FROM shops 
LEFT JOIN expiration ON shops.id=expiration.shopid
GROUP BY shopid
ORDER BY
  MAX(shops.grade) DESC,
  MIN(expiration.startdate) ASC,
  MAX(expiration.enddate) DESC,
  shops.id

Monday, 20 April 2020

India - All State Name in Json format

{
"AN":"Andaman and Nicobar Islands",
"AP":"Andhra Pradesh",
"AR":"Arunachal Pradesh",
"AS":"Assam",
"BR":"Bihar",
"CG":"Chandigarh",
"CH":"Chhattisgarh",
"DN":"Dadra and Nagar Haveli",
"DD":"Daman and Diu",
"DL":"Delhi",
"GA":"Goa",
"GJ":"Gujarat",
"HR":"Haryana",
"HP":"Himachal Pradesh",
"JK":"Jammu and Kashmir",
"JH":"Jharkhand",
"KA":"Karnataka",
"KL":"Kerala",
"LA":"Ladakh",
"LD":"Lakshadweep",
"MP":"Madhya Pradesh",
"MH":"Maharashtra",
"MN":"Manipur",
"ML":"Meghalaya",
"MZ":"Mizoram",
"NL":"Nagaland",
"OR":"Odisha",
"PY":"Puducherry",
"PB":"Punjab",
"RJ":"Rajasthan",
"SK":"Sikkim",
"TN":"Tamil Nadu",
"TS":"Telangana",
"TR":"Tripura",
"UP":"Uttar Pradesh",
"UK":"Uttarakhand",
"WB":"West Bengal"
}

Saturday, 11 April 2020

How to use Way2Sms api in C#

public void send(string message, string no)
{

HttpWebRequest myReq =
// (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
//"&msg=" + message + "&phone=" + no + "&provider=way2sms");
(HttpWebRequest)WebRequest.Create("puturlink = "+"UrUsername"+ "&password=" + "UrPassword" + "&sender=" +"UrSenderID"+ "&to=" +no+ "&message=" + message+ "&reqid=1&format={json|text}&route_id=route+id&callback=Any+Callback+URL&unique=1&sendondate=" +"10-10-2014T05:17:52"+"");
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}

//Button Click code
protected void btn_send_Click(object sender, EventArgs e)
{

send(txt_message.Text, txt_mobile.Text);

ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('sms sent successfully...');", true);

}

Sunday, 5 April 2020

EXEC sp_configure for SP procedure

EXEC sp_configure 'Ole Automation Procedures';
GO

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO


3
4
5
6
7
8
9
10
11
DECLARE @status int
DECLARE @responseText as table(responseText nvarchar(max))
DECLARE @res as Int;
DECLARE @url as nvarchar(1000) = 'https://www.google.it'
EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @res OUT
EXEC sp_OAMethod @res, 'open', NULL, 'GET',@url,'false'
EXEC sp_OAMethod @res, 'send'
EXEC sp_OAGetProperty @res, 'status', @status OUT
INSERT INTO @ResponseText (ResponseText) EXEC sp_OAGetProperty @res, 'responseText'
EXEC sp_OADestroy @res
SELECT @status, responseText FROM @responseText

redirect to new page from jquery

  function foo(id) { var url = ' @Url . Action ( "Details" , "Branch" , new { id = "__id__" })'...