Tuesday, May 27, 2025
Saturday, June 3, 2023
Dynamic Pivot Results to a Temp Table
Dynamic Pivot Results to a Temp Table
SET @cols = STUFF((SELECT distinct ',' + QUOTENAME(QT.QUESTION_DESC)
FROM #QUES_TEMP QT
GROUP BY QT.QUESTION_DESC
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set @query = 'SELECT EVAL_ID, AuditType, ' + @cols + '
from
(
select QT.EVAL_ID,
QT.AuditType,
QT.SCORE,
QT.QUESTION_DESC
from #QUES_TEMP QT
) x
pivot
(
max(SCORE)
for QUESTION_DESC in (' + @cols + ')
) p '
set @query = 'select * into ##Temp from ('+@query+') y'
execute(@query)
select * from ##Temp
Source :: https://stackoverflow.com/questions/22503366/dynamic-pivot-results-to-a-temp-table
Tuesday, March 21, 2023
Close the dialog box of jQuery
$(document).ready($(function () { $('#searchFacility').button().on("click", function () { //showUrlInDialog('/Home/FacilitySearch'); $("#modalSearch").load('/Home/FacilitySearch').dialog({ autoOpen: false, modal: true, close: function (event, ui) { $("#modalSearch").empty().dialog('destroy'); alert('Dialog closing'); } }).dialog('open'); return false; });
$(document).ready($(function () {
$("#btnCancel").button().on("click", function () {
alert('hi');
$("#modalDialog").dialog('close');
});
}));
Saturday, March 11, 2023
Top 10 Websites to Help Programmers
1. https://stackoverflow.com/
2. https://www.c-sharpcorner.com/
3.https://www.datensen.com/
4. https://coderbyte.com/
5. https://www.codewars.com/
6. https://www.codingame.com/
7. https://geektastic.com/
8. https://www.hackerrank.com/
9. https://leetcode.com/
10. https://www.tutorialspoint.com/
11. https://www.w3schools.com/
12. https://www.sqlservertutorial.net/
13. https://www.canva.com/
Wednesday, March 8, 2023
Multiple like search In SQL Server
Multiple like search In SQL Server
SELECT Tbla.* FROM Tbla
INNER JOIN Tblb ON
Tblb.col1 Like '%'+Tbla.Col2+'%'
Help Link : https://stackoverflow.com/questions/1865353/combining-like-and-in-for-sql-server
FROM( SELECT OBD.orderRowNo,OBD.OrderBookingID,OBD.OrderDetailBodyID,OBD.FabricDia,OBD.FabricGSM,OBD.KnittingOrderQty,OBD.DyeingOrderQty,FabricFormID,ColorID,OBD.FabricTypeID,OBD.YarnTypeID,OBD.MeasureUnitID,OBD.GarmentsColor
FROM
tblOrderBookingDetailBody OBD INNER JOIN tblOrderBookingHead OH ON OH.OrderBookingID=OBD.OrderBookingID
WHERE OH.OrderCurrentStatus=2) FX INNER JOIN #Orderinfo Tblb ON
FX.YarnTypeID Like '%'+CAST(Tblb.YarnTypeID AS VARCHAR)+'%'
AND FX.FabricFormID Like '%'+ CAST(Tblb.FabricFormID AS VARCHAR)+'%'
AND FX.ColorID Like '%'+ CAST(Tblb.ColorID AS VARCHAR)+'%'
AND FX.FabricTypeID Like '%'+ CAST(Tblb.FabricTypeID AS VARCHAR)+'%'
AND FX.FabricDia Like '%'+Tblb.FabricDia+'%'
AND FX.FabricGSM Like '%'+Tblb.FabricGSM+'%'
Monday, February 6, 2023
SQL SERVER TCP/IP Configuration
Enable TCP/IP in SQL Server Configuration
When two or more SQL Servers are connected across network they do all communication using TCP/IP. The default port of SQL Server installation is 1433. This port can be changed through SQL Server Configuration Manager. TCP/IP should be enabled for SQL Server to be connected.
- Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select TCP/IP
- Right Click on TCP/IP >> Click on Enable
You must restart SQL Server Services for all the changes to take effect. Right click and go to menu properties to select location where default port of SQL Server can be changed.
Reference Link ::
https://stackoverflow.com/questions/18060667/cannot-connect-to-server-a-network-related-or-instance-specific-error
Monday, June 27, 2022
How to Solving debugging error in Visual studio
Resolving breakpoint will not be hit error ways
- We will start with simple solution, try to clean your solution and then re-build. For this, simply open your "Solution Explorer", select your "Solution" and right click on it, Select "Clean Solution", once solution is cleaned, which will delete all the compiled and temporary files associated with a solution, select "Build" solution and then check if issue exists.
- Make sure, you have set configuration to "Debug" mode and you are not working on "Release" mode while debugging your application.
- If the above 2 methods doesn't work for you, you can try for second method to make sure, your .NET solution is confugured properly, follow these steps
- Right click on your project name
- Select Properties
- Select the "Build" tab
- Make sure "Define DEBUG constant" and "Define TRACE constant" are checked
- Make sure "Optimize Code" is unchecked
- Click the "Advanced" button at the bottom of the Build tab page
- Make sure that "Debug Info:" is set to "full"
- Click "Ok" and re-build your project.
- If all of the above steps, doesn't work for you, you can try to disable the "Just My Code" option in the Debug/General settings.
For this navigate to "debug" -> select "options" and then from right-pane, de-select "Enable just my code"
Friday, January 14, 2022
Tuesday, January 4, 2022
Date and Time Conversions Using SQL Server
select convert(varchar, getdate(), 1) mm/dd/yy 12/30/06
select convert(varchar, getdate(), 2) yy.mm.dd 06.12.30
select convert(varchar, getdate(), 3) dd/mm/yy 30/12/06
select convert(varchar, getdate(), 4) dd.mm.yy 30.12.06
select convert(varchar, getdate(), 5) dd-mm-yy 30-12-06
select convert(varchar, getdate(), 6) dd-Mon-yy 30 Dec 06
select convert(varchar, getdate(), 7) Mon dd, yy Dec 30, 06
select convert(varchar, getdate(), 10) mm-dd-yy 12-30-06
select convert(varchar, getdate(), 11) yy/mm/dd 06/12/30
select convert(varchar, getdate(), 12) yymmdd 061230
select convert(varchar, getdate(), 23) yyyy-mm-dd 2006-12-30
select convert(varchar, getdate(), 101) mm/dd/yyyy 12/30/2006
select convert(varchar, getdate(), 102) yyyy.mm.dd 2006.12.30
select convert(varchar, getdate(), 103) dd/mm/yyyy 30/12/2006
select convert(varchar, getdate(), 104) dd.mm.yyyy 30.12.2006
select convert(varchar, getdate(), 105) dd-mm-yyyy 30-12-2006
select convert(varchar, getdate(), 106) dd Mon yyyy 30 Dec 2006
select convert(varchar, getdate(), 107) Mon dd, yyyy Dec 30, 2006
select convert(varchar, getdate(), 110) mm-dd-yyyy 12-30-2006
select convert(varchar, getdate(), 111) yyyy/mm/dd 2006/12/30
select convert(varchar, getdate(), 112) yyyymmdd 20061230
TIME ONLY FORMATS
8 select convert(varchar, getdate(), 8) hh:mm:ss 00:38:54
14 select convert(varchar, getdate(), 14) hh:mm:ss:nnn 00:38:54:840
24 select convert(varchar, getdate(), 24) hh:mm:ss 00:38:54
108 select convert(varchar, getdate(), 108) hh:mm:ss 00:38:54
114 select convert(varchar, getdate(), 114) hh:mm:ss:nnn 00:38:54:840
DATE & TIME FORMATS
0 select convert(varchar, getdate(), 0) Mon dd yyyy hh:mm AM/PM Dec 30 2006 12:38AM
9 select convert(varchar, getdate(), 9) Mon dd yyyy hh:mm:ss:nnn AM/PM Dec 30 2006 12:38:54:840AM
13 select convert(varchar, getdate(), 13) dd Mon yyyy hh:mm:ss:nnn AM/PM 30 Dec 2006 00:38:54:840AM
20 select convert(varchar, getdate(), 20) yyyy-mm-dd hh:mm:ss 2006-12-30 00:38:54
21 select convert(varchar, getdate(), 21) yyyy-mm-dd hh:mm:ss:nnn 2006-12-30 00:38:54.840
22 select convert(varchar, getdate(), 22) mm/dd/yy hh:mm:ss AM/PM 12/30/06 12:38:54 AM
25 select convert(varchar, getdate(), 25) yyyy-mm-dd hh:mm:ss:nnn 2006-12-30 00:38:54.840
100 select convert(varchar, getdate(), 100) Mon dd yyyy hh:mm AM/PM Dec 30 2006 12:38AM
109 select convert(varchar, getdate(), 109) Mon dd yyyy hh:mm:ss:nnn AM/PM Dec 30 2006 12:38:54:840AM
113 select convert(varchar, getdate(), 113) dd Mon yyyy hh:mm:ss:nnn 30 Dec 2006 00:38:54:840
120 select convert(varchar, getdate(), 120) yyyy-mm-dd hh:mm:ss 2006-12-30 00:38:54
121 select convert(varchar, getdate(), 121) yyyy-mm-dd hh:mm:ss:nnn 2006-12-30 00:38:54.840
126 select convert(varchar, getdate(), 126) yyyy-mm-dd T hh:mm:ss:nnn 2006-12-30T00:38:54.840
127 select convert(varchar, getdate(), 127) yyyy-mm-dd T hh:mm:ss:nnn 2006-12-30T00:38:54.840
ISLAMIC CALENDAR DATES
130 select convert(nvarchar, getdate(), 130) dd mmm yyyy hh:mi:ss:nnn AM/PM
131 select convert(nvarchar, getdate(), 131) dd mmm yyyy hh:mi:ss:nnn AM/PM 10/12/1427 12:38:54:840AM
You can also format the date or time without dividing characters, as well as concatenate the date and time string:
Sample statement Format Output
select replace(convert(varchar, getdate(),101),'/','') mmddyyyy 12302006
select replace(convert(varchar, getdate(),101),'/','') + replace(convert(varchar, getdate(),108),':','') mmddyyyyhhmmss 12302006004426
Wednesday, December 1, 2021
Multiple case function in sqlserver
Example::::
SELECT GreyReceiveTypeName,
FROM TBL...XYZ
CASE GreyReceiveTypeName WHEN 'Bulk' THEN 'Bulk' WHEN 'Sample' THEN 'Sample' WHEN 'Order Related Sample' THEN 'Sample'
WHEN 'Others Sample' THEN 'Sample' WHEN 'RETURN' THEN 'RETURN' WHEN 'Replacement' THEN 'Replacement' WHEN 'Coller Cuff' THEN 'Coller Cuff' WHEN 'Coller Cuff' THEN 'Short Qty'
WHEN 'Process Loss Qty' THEN 'Process Loss Qty' ELSE '' END ProductionType
Monday, December 7, 2020
Table multiple Add Row and Delete Row In jquery
var ItemList = [];
function GetSecurity_RosterShiftDetails() {
var obj = {
RosteID: $('#dlRoster').val(),
EmployeeID: $('#txtEmployeeID').val(),
ShiftID: $('#dlShifts').val(),
StartDate: $('#txtShiftStartDate').val()
}
//var PostList = PostList.substring(0, PostList.length - 1);
$.ajax({
type: "POST",
url: '@Url.Action("GetSecurity_OTEmployee", "SecurityRoster")',
dataType: "JSON",
data: JSON.stringify({ "obj": obj }),
contentType: "application/json;charset=utf-8",
success: function (data) {
if (data.length > 0) {
var item = "";
$.each(data, function (i, obj) {
var button = '<button class="" style="padding: 1px 10px;background:green;color:white;" onclick="ReplaceGuard(' + obj.RosterOTID + ',\'' + obj.EmployeeID + '\')">Replace</button>' +
'<button class="" style="padding: 1px 10px;background:red;color:white;" onclick="Delete(' + obj.RosterOTID + ')">Del</button>';
if (obj.IsDeleted == 1) {
var button = '<span style="padding: 1px 10px;color:red;background:#f6fb66;font-weight:bold;">Deleted</span>' +
'<a class="" style="padding: 1px 3px;font-weight:bold;cursor:pointer;"title="UNDO This Data." onclick="Undo(' + obj.RosterOTID + ')"><u>UNDO</u></a>';
}
var updatevalue = "";
if (obj.RosterOTID == "" || obj.RosterOTID == null) {
updatevalue = "SaveData()";
} else {
updatevalue = 'updateData(' + obj.RosterOTID + ')';
}
var exot = $("#Exot").val();
var maxlenth = "";
var readonly = "";
if (exot == "EX.OT") {
maxlenth = "";
readonly = "";
} else {
maxlenth = 'maxlength="2"';
readonly = "readonly";
}
var Dayoff = "";
if (obj.Dayoff == "" || obj.Dayoff == "") {
Dayoff = "";
} else {
Dayoff = "background-color:yellow;";
}
//alert(obj.EmployeeOT);
var newRow = '';
item += '<tr style="text-align:center;'+Dayoff+'">' +
'<td alt="RosterShiftDetailsID" style="display:none;">' + obj.RosterShiftDetailsID + '</td>' +
'<td alt="GuardListID" style="display:none;">' + obj.GuardListID + '</td>' +
'<td style="width:12px;">' + (i + 1) + '</td>' +
'<td style="text-align:left;padding-left:10px;">' + obj.Shift + '</td>' +
'<td style="text-align:left;padding-left:10px;">' + obj.EmployeeName + '</td>' +
'<td>' + obj.EmployeeID + '</td>' +
'<td>' + obj.Designation + '</td>' +
'<td style="width:150px;"><input value="' + obj.ShiftName + '" id="txtShiftName_' + (i + 1) + '" type="text" style="width:100px;" list="dlShift" class="dlShift"/></td>' +
'<td style="width:150px;"><input ' + maxlenth + ' value="' + obj.StartTime + '" id="txtStartTime" type="text" style="width:100px;" class="txtStartTime"/></td>' +
'<td style="width:150px;"><input ' + maxlenth + ' value="' + obj.EndTime + '" id="txtEndTiime" type="text" style="width:100px;" class="txtEndTime"/></td>' +
'<td style="width:220px;"><input value="' + obj.PostName + '" id="txtPostName_' + (i + 1) + '" type="text" style="width:220px;" list="dlPostName" class="dlPostName"/></td>' +
'<td style="width:75px;"><input ' + readonly + ' value="' + obj.Hours + '" id="txtHour" type="text" style="width:70px;background-color: aquamarine;" class="txtHour"/></td>' +
'<td><a onclick="OTinformationDetails(' + obj.GuardListID + ')" rel="">' + obj.EmployeeOT + '</a></td>' +
'<td style="width:75px;"><button class="btn btn-success" type="button" onclick="' + updatevalue + '">Save</button></td>' +
'<td style="width:150px;">' + button + '</td>' +
'<td style="width:150px;display:none;">' + obj.RosterOTID + '</td>' +
'<td style="' + newRow + '"><img src="../Images/Global/add-image.png" style="height:25px; width:25px" alt="Add Row" class="AddFRRow"/><img src="../Images/Global/delete-image.png" style="height:25px; width:25px" alt="delete Row" class="DelFRRow"/></td>' +
'</tr>';
});
$("#tbodyShift").html(item);
console.log(ItemList);
} else {
$("#tbodyShift").html('');
}
}
});
}
$(document).on('click', '.AddFRRow', function () {
var indx = $(this).closest('tr').index();
var content = '<tr style="height:25px">' + $(this).closest('tr').html() + '</tr>';
$('#tableShift tr:eq(' + (indx + 1) + ')').after(content);
$tr = $(this).closest("tr").clone();
$tr.insertAfter($(this).closest("tr"));
$('#tableShift tr:eq(' + (indx + 2) + ')').addClass('gridclick');
});
$(document).on('click', '.DelFRRow', function () {
var id = $(this).closest('tr').children('td:eq(29)').text();
FRRowID = $(this).closest('tr').children('td:eq(29)').text();
//$(this).closest('tr').remove();
if (id == '0' || id == 'X') {
$(this).closest('tr').remove();
//ShowCustomDialog('Row Deleted.', 'Fast React');
}
else {
//btnID = 'FRDelete';
//msg = 'Are you sure want to Delete this Color From FastReact ?';
//OpenConfirmDialog();
Show_Alert('You Can Not Delete Saved Info From FastReact.', 'W');
}
});
});
copy-table-row-and-copy-data-from-table-column
https://www.jqueryscript.net/demo/duplicate-remove-rows-patuta/
<div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('#btnTransfer').on('click', function () {
var tr = $("#dvOrders").find("TR:has(td)").clone();
$("#main").append(tr);
});
});
</script>
<img alt="" style="cursor: pointer" src="../images/plus.png">
<table id="dvOrders" class="secondtable">
<tbody>
<tr>
<th>
S.No
</th>
<th>
S.ID
</th>
<th>
tid
</th>
<th>
topic name
</th>
<th>
video url
</th>
<th>
Notes url
</th>
<th>
tdesc
</th>
<th>
assignid
</th>
<th>
assign name
</th>
<th>
free
</th>
</tr>
<tr>
<td>
</td>
<td>
3
</td>
<td>
8
</td>
<td>
Hello NEW
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
1
</td>
<td>
<input type="text" />
</td>
<td>
True
</td>
</tr>
<tr>
<td>
</td>
<td>
3
</td>
<td>
8
</td>
<td>
Hello NEW
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
1
</td>
<td>
<input type="text" />
</td>
<td>
True
</td>
</tr>
</tbody>
</table>
</div>
<br />
<input type="button" onclick="" value="NEW EXTEA OT" id="btnTransfer" />
<table id="main">
<tr>
<th>
S.No
</th>
<th>
S.ID
</th>
<th>
tid
</th>
<th>
topic name
</th>
<th>
video url
</th>
<th>
Notes url
</th>
<th>
tdesc
</th>
<th>
assignid
</th>
<th>
assign name
</th>
<th>
free
</th>
</tr>
</table>
</div>