Showing posts with label newly. Show all posts
Showing posts with label newly. Show all posts

Wednesday, March 21, 2012

GetChanges Update problem

I have the below C# routine which is working but now I need to write its newly randomized L_Rank values back up to the Sql Server. How can i do that in Button1_Click? DataTable 'dt' contains only two fields - L_ID and L_Rank. I have a stored procedure but I do not know how to call it in Button1_Click and pass the parameters it is looking for.

SP:
PROCEDURE RandomizeLinks
@.L_ID int,
@.L_Rank int
AS
UPDATE tblLinkInfo_OLD2 SET L_Rank = @.L_Rank
WHERE (L_ID = @.L_ID)

protected void Button1_Click(object sender, EventArgs e)
{
GetRandLinks();
DataTable dt = GetRandLinks();
int RowIncrement;
RowIncrement = 0;
System.Random myRandom = new System.Random();
foreach (DataRow row in dt.Rows)
{
int LinkRank = myRandom.Next(25, 250);
row["L_Rank"] = LinkRank;
RowIncrement++;
}

Is what I want to do possible - it seems easy but nothing I do works.

|||

Am I asking the question wrong - Can you use a DataTable to update a SQL Table and can it be done in a batch UPDATE as opposed to incrementing through every row?

|||

anyone?

Wednesday, March 7, 2012

Get table row size

How can we get the newly inserted row's size from a SQL Server table?

Quote:

Originally Posted by soumyamathewmca

How can we get the newly inserted row's size from a SQL Server table?


select
sys.objects.[name],
sys.objects.[object_id],
count(sys.columns.[name]) As ColumnCount,
sum(sys.columns.max_length) As MaxLength
from
sys.objects
inner join sys.columns on sys.objects.object_id = sys.columns.object_id
where
sys.objects.[name] = Table_Name
group by
sys.objects.[name],
sys.objects.[object_id]