Monday, May 17, 2010
tsql INSERT INTO for bulk copy of records from SqlServer table to table
I have been using tsql
Select * into Tbl2 from Tbl1 where FName = 'David'
for a long time, as a shortcut to create new table Tbl2, a copy of Tbl1 including schema and data.
I'm glad I finally found out about :
Insert into Tbl2 ( LastName , FirstName , AdmitDate) select Last, First, RevDate from Tbl1 where FName = 'David'
to use when Tbl2 is already in existence.
Select * into Tbl2 from Tbl1 where FName = 'David'
for a long time, as a shortcut to create new table Tbl2, a copy of Tbl1 including schema and data.
I'm glad I finally found out about :
Insert into Tbl2 ( LastName , FirstName , AdmitDate) select Last, First, RevDate from Tbl1 where FName = 'David'
to use when Tbl2 is already in existence.
Friday, May 14, 2010
Calling all Technical Women in Technology for...
What we have all been waiting for ...
A NJ Technical Women in Technology
Event
Register Now ->
Recommended Audiences: IT Professionals, Administrators, Developers, Architects
Are you a Technical Women in Technology?
Are you tired of always being surrounded by technical males that don't ____ (fill in the blank)?
Are you tired of trying to explain your technical issues to other women that just don't get it?
Are you looking to connect with other women with common interests?
Then, you may be interested in helping to form a Technical Women in Technology Group...
Refreshments: Appetizers & Water/Soda
Sponsors: Microsoft / SetFocus
Purpose:
To allow NJ Technical Women in Technology to meet and to discuss a future direction for a group
Event Updates: updates
Agenda:
Overview
Attendee Introductions
Panel Discussion (2-3 women sharing their experiences as a Technical Women in Technology
Future Direction Discussion - In-Person and/or Virtual meetings, frequency, meeting content, etc.
For Additional Information about how you can help kick start this community, please email melissa[@]sqldiva.com.
Event
Register Now ->
Recommended Audiences: IT Professionals, Administrators, Developers, Architects
Are you a Technical Women in Technology?
Are you tired of always being surrounded by technical males that don't ____ (fill in the blank)?
Are you tired of trying to explain your technical issues to other women that just don't get it?
Are you looking to connect with other women with common interests?
Then, you may be interested in helping to form a Technical Women in Technology Group...
Refreshments: Appetizers & Water/Soda
Sponsors: Microsoft / SetFocus
Purpose:
To allow NJ Technical Women in Technology to meet and to discuss a future direction for a group
Event Updates: updates
Agenda:
Overview
Attendee Introductions
Panel Discussion (2-3 women sharing their experiences as a Technical Women in Technology
Future Direction Discussion - In-Person and/or Virtual meetings, frequency, meeting content, etc.
For Additional Information about how you can help kick start this community, please email melissa[@]sqldiva.com.
Tuesday, April 27, 2010
Include a derived control in my aspx page
register control at top of page giving it a TagPrefix:
use tag prefix and control name in aspx
"CtrlClass" is the derived control class name, which is in a cs file name doesn't matter, but namespace is "iNamespceInCsFile" in project ="iProjectName".
public class Comment2 : TextBox
{ etc ...
<%@ Register Assembly="iProjectName" Namespace="iNamespceInCsFile" TagPrefix="ifc" %>
use tag prefix and control name in aspx
<ig:TemplateDataField Key="key1" Width="30px">
<ItemTemplate>
<ifc:CtrlClass ID="id1" runat="server" Text='<%# Eval "BoundCol1") %>' />
</ItemTemplate>
</ig:TemplateDataField>
"CtrlClass" is the derived control class name, which is in a cs file name doesn't matter, but namespace is "iNamespceInCsFile" in project ="iProjectName".
public class Comment2 : TextBox
{ etc ...
Tuesday, March 23, 2010
Comparison of ig bound Templated Checkbox to boolean BoundDataField
Shows up as text "true" or "false": <ig:BoundDataField DataFieldName="IsCostSaving" Key="IsCostSaving" width="30px">
<Header Text="Cost Saving" />
</ig:BoundDataField>
Shows up as a checkbox with checked value picked up from bound field:
<ig:TemplateDataField Key="cb1" width="30px">
<Header Text="Cost Saving" />
<ItemTemplate>
<asp:CheckBox ID="cb1" runat="server" Checked='<%# Eval("IsCostSaving") %>' Enabled="false" />
</ItemTemplate>
</ig:TemplateDataField>
Monday, March 22, 2010
Looping thru Infragistics WebDataGrid on the Server
Took me a while to find this. With some help from ig, thank you Chandradeep!
protected void Button1_Click(object sender, EventArgs e)
{
// loop thru selected cells and get their values
foreach (GridRecordItem itm in WebDataGrid1.Behaviors.Selection.SelectedCells)
{
object ttt = itm.Text ;
}
// example of looping thru selected rows and getting values of columns
foreach (GridRecord row in WebDataGrid1.Behaviors.Selection.SelectedRows)
{
object ttt = row;
GridRecordItem itm = row.Items[0];
string sffssdf = itm.Text;
itm = row.Items[1];
sffssdf = itm.Text;
itm = row.Items[2];
sffssdf = itm.Text;
}
// example of looping thru all rows and getting values of columns
foreach (GridRecord row in WebDataGrid1.Rows)
// foreach (GridRecordItem row in WebDataGrid1.Behaviors.Selection.SelectedCells)
{
object ttt = row;
GridRecordItem itm = row.Items[0];
string sffssdf = itm.Text;
itm = row.Items[1];
sffssdf = itm.Text;
itm = row.Items[2];
sffssdf = itm.Text;
}
// example of looping thru all rows and getting values of a checkbox in a column template field!!!!!
foreach (GridRecord row in WebDataGrid1.Rows)
// foreach (GridRecordItem row in WebDataGrid1.Behaviors.Selection.SelectedCells)
{
CheckBox theCB = (CheckBox)row.Items[0].FindControl("cb1");
bool ischecked = theCB.Checked;
object ttt = row;
GridRecordItem itm = row.Items[0];
string sffssdf = itm.Text;
itm = row.Items[1];
sffssdf = itm.Text;
itm = row.Items[2];
sffssdf = itm.Text;
}
}
Tuesday, March 16, 2010
Case sensitive column contents in SqlServer
Use the following t-sql code to make the contents of a column case sensitive regardless of the default db setting:
alter table TheTableName alter column TheColumnName TypeOfColEgVarchar(20)OrChar(6) collate Latin1_General_CS_AS
for example:
alter table People alter column LastName varchar(20) collate Latin1_General_CS_AS
Am using this in SqlServer 2005.
alter table TheTableName alter column TheColumnName TypeOfColEgVarchar(20)OrChar(6) collate Latin1_General_CS_AS
for example:
alter table People alter column LastName varchar(20) collate Latin1_General_CS_AS
Am using this in SqlServer 2005.
Thursday, January 28, 2010
Leading zeros in tsql
select right ('StringOfZerosAsManyAsMaxNeededMoreIsOK'
+ cast ( AnIntegerLiteralOrIntVariable as varchar)
, IntLiteralWhichIsTotalLengthOfNeededString)
declare @counter int
set @counter = 126
select right ('000000' + cast ( @counter as varchar) , 6 )
result:
000126
declare @counter int
set @counter = 12345678
select right ('000000000' + cast ( @counter as varchar) , 6 )
result:
345678
declare @counter int
set @counter = 123
select right ('00' + cast ( @counter as varchar) , 6 )
result:
00123
declare @counter int
set @counter = 123
select right ('0000' + cast ( 123 as varchar) , 9 )
result:
000126
+ cast ( AnIntegerLiteralOrIntVariable as varchar)
, IntLiteralWhichIsTotalLengthOfNeededString)
declare @counter int
set @counter = 126
select right ('000000' + cast ( @counter as varchar) , 6 )
result:
000126
declare @counter int
set @counter = 12345678
select right ('000000000' + cast ( @counter as varchar) , 6 )
result:
345678
declare @counter int
set @counter = 123
select right ('00' + cast ( @counter as varchar) , 6 )
result:
00123
declare @counter int
set @counter = 123
select right ('0000' + cast ( 123 as varchar) , 9 )
result:
000126
Subscribe to:
Posts (Atom)