|
Do you need to whole row or just the ID? You could try something like this for the whole row:
SELECT * FROM tblSomething WHERE tblID = IDENT_CURRENT('tblSomething')
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
|
but when your ids are uniqueidentifiers you do have a the current id do you? and i'm not necersary selecting in the at the same time when the rows are selected.
La Light
|
|
|
|
|
If the table has an Identity field (ID) or a created date field then this is fairly easy
<br />
select top 1 * from table<br />
ORDER BY myfield DESC<br />
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
But my Ids are uniqueidentifier so i cant not do it by a exacly field
La Light
|
|
|
|
|
How can i merge two tables based on ids? I want to display everything from one table and append columns with matched ids from another table. See example below.
Table 1
id col1 col2 col3
1 a b c
2 d e f
3 g h i
Table 2
id colx coly colz
2 T U V
Final result:
id col1 col2 col3 colx coly colz
1 a b c
2 d e f T U V
3 g h i
I'll appreciate any help thanks.
|
|
|
|
|
select a.id, a.col1, a.col2, a.col3, b.colx, b.coly, b.colz
from table1 a left outer join table2 b on a.id = b.id
Mike Lasseter
|
|
|
|
|
Hi,
i have to extract datetime field of table in database stored in
mm/dd/yyyy 12:00:00 and display it in repeater in MM.dd.yyyy format.
Time should not be displayed ,date should be displayed in MM.dd.yyyy foemat only that is having dots not slashes.
How can i achieve it?
Is there any function in SQL to convert date format?.Please guide.
yog
hui gfgh kgdgrt njjn hjgkn
|
|
|
|
|
Try this:
DateTime myDate = dateFromDB;
string myDateStringForm = myDate.ToString("mm.dd.yyyy");
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
i dont want to save it as an string i want to handle it as date how do you do that?
La Light
|
|
|
|
|
You need a string if you are binding it to a Text property of the control.
If you do not want to declare a string variable, do it in one line:
myControl.Text = myDate.ToString("MM.dd.yyyy");
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
replace(convert(varchar,getdate(),101),'/','.')
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
hello
i'm trying to write a query that returns the primary key field and its attributes of a given table. the table name is given at runtime through a dropdown menu.
i encounter many problems.
can anyone please tell me what query to use for this purpose????
please reply soon.
awaiting ur reply
Saira
|
|
|
|
|
Saira Tanwir wrote: i encounter many problems.
Can you explain in details, what problems you are facing and the query you are using ?
Saira Tanwir wrote: please reply soon.
If you specify the complete details in your question itself, I am sure you will get lot of replies and you wont waste your time.
Next time please specify complete details in your postings.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
ok!
the query i'm using top retrieve the primary keys of all tables in the database is
sql="SELECT name FROM sysobjects WHERE xtype='PK'";
when i execute this query through
DataTable pkey=new DataTable();<br />
sql="SELECT name FROM sysobjects WHERE xtype='PK'";<br />
cmd=new SqlCommand(sql, conn);<br />
reader=cmd.ExecuteReader();<br />
pkey=reader.GetSchemaTable();<br />
reader.Close();<br />
if(pkey!=null)<br />
{<br />
dataGrid2.DataSource=pkey;<br />
}
the output i get is always the same i.e. always only one column name is returned with its attributes and the column name is always 'name'.
i've also tried the following queries:
sql="SELECT name FROM sysobjects WHERE xtype='PK' AND name='name'";
the result is still the same
Saira
|
|
|
|
|
Hi coolestcoder
i've just got the desired result from the query, by changing me logic from SQLDataReader to SQLDataAdapter.
now i have all the primary keys in the entire DB.
now i want a query which gives me the primary key with respect to its table name. can u please guide me through the query that gives me the desired results.
Saira
|
|
|
|
|
|
Saira Tanwir wrote: i've just got the desired result from the query, by changing me logic from SQLDataReader to SQLDataAdapter.
That was not the reason. The reason was that you were not actually reading the DATA from the data reader, you were reading the schema of the result set. Your SQL Query specified that your result set contained just one column called "name".
|
|
|
|
|
U can try this code--
first u feel the dataset by adapter pass datatable to this function-
Private Sub GetPrimaryKeys(table As DataTable)
' Create the array for the columns.
Dim columns() As DataColumn
columns = table.PrimaryKey
' Get the number of elements in the array.
msgbox("Column Count: " & columns.Length.ToString())
Dim i As Integer
For i = 0 To columns.GetUpperBound(0)
msgbox(columns(i).ColumnName & columns(i).DataType.ToString())
Next i
End Sub
Keep Smiling !!!
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
i want read mouse data from ps2 port with my application
i know mouse data format that send to ps2 port but i don't know
how read from ps2 port
|
|
|
|
|
The PS2 port is a serial device ( i.e. com port ). If you already have a driver installed reading the mouse you may be able to "hook" in to that or else you can write your driver. You need to know some low level code to read of the com port.
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
Using SQL ?
Christian Graus - C++ MVP
|
|
|
|
|
The boy likes a challenage
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
i need to swap variable.how to swap in sql .
i need syntax about swapping with 'if' and 'forloop' conditions
Smitha
|
|
|
|
|
prameelapydi wrote: i need to swap variable.how to swap in sql .
What do you mean by "swap variable"?
|
|
|
|
|
Some thing like this
<br />
@Declare @MyVar1 int <br />
@Declare @MyVar2 int<br />
@Declare @MyVar3 int<br />
<br />
SET @MyVar1 = 1<br />
SET @MyVar2 = 2<br />
<br />
------- Swap @MyVar1 @MyVar2 -------------------<br />
<br />
SET @MyVar3 = @MyVar1<br />
<br />
SET @MyVar1 = @Myvar2<br />
<br />
SET @MyVar2 = @MyVar3<br />
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|