|
how to convert a string to integer of length 4?which function to use?
P.PaVaN KuMaR
|
|
|
|
|
select convert(int,ColumnName) from TableName
or
select cast(ColumnName as int) from TableName
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I would suggest to add the isnumeric function if you are not absolutely sure that the string ALWAYS contains valid ints:
select cast( case when isnumeric(ColumnName)=1 then ColumnName else NULL end as int ) from TableName
Regards,
Rainer.
Rainer Stropek
Visit my blog at http://www.cubido.at/rainers
|
|
|
|
|
r.stropek wrote: select cast( case when isnumeric(ColumnName)=1 then ColumnName else NULL end as int ) from TableName
Makes sense. Thanks.
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
how to insert a boolean variable into sql table?it needs any conversion?give one example.
P.PaVaN KuMaR
|
|
|
|
|
|
i want a datetime format as mm/dd/yyyy in dataset i am getting
AcquisitionDate="2005-05-05T00:00:00+05:30"
if i used convert(datetime,AcquisitionDate) function ,the sql is throwing error convertion failed to datetime as character string
any other way to convert this
guide me please
-
|
|
|
|
|
It is too simple..
try this out...
--> convert(char,getdate(),101) <--function
....
vivek
|
|
|
|
|
I have a system which uses dynamic forms generated from XML, it saves the results in XML to a seperate table and combines the two on reload but I need a fast way of searching the XML and looking for suggestions, the data is stored like this:
<field name="<fieldname>" value="<somevalue>">
I was thinking of using something like:
SELECT * FROM xmldatatable WHERE xmldata LIKE 'value="%<searchterm>%"';
Would this be acceptable? I would imagine it would start to get very slow once the record numbers start increasing?
(Using PostgreSQL 8.1)
|
|
|
|
|
Have you thought about using XPath?
|
|
|
|
|
hi
i am writing a quert to select all the columns from a table just like that
select Eaton.* from Eaton
eaton is my table name but some colums has blank spacesin left and right so i want to eliminate them so i use
select Trim(Eaton.*) from Eaton but its not woking
Whast i do if any body know Please help
Thank in advance
Thanks
|
|
|
|
|
Use ltrim or rtrim
as below:
select lTRIM('Eaton.* ')
between (')
|
|
|
|
|
hi all...
i have a problem that how to show a date in access table.. can someone please help me..
areon25
|
|
|
|
|
Hi There
This has got to be an easy one... I am coming to ADO.NET from an ADO background, so i appologise if it comes across as totally stupid!
All i want to do is insert a new row into a table and pull back the autonumber primary key assigned to it.
What i don't want to have to do is:
1) Fill a Dataset in order to get a DataTable definition.
2) Use stored procedures.
Anybody know the answer off the top of their head? Guess i really need to buy a good ADO.NET book.
Thanks In Advance
Rich
|
|
|
|
|
|
this is my query
query="SELECT studenti.Nume, studenti.Prenume, cursuri.denumire_curs, note.nota, note.data " +
"FROM studenti INNER JOIN " +
"(profesori INNER JOIN " +
"(cursuri INNER JOIN [note] ON cursuri.id_curs = note.id_curs) " +
"ON profesori.id_profesor = cursuri.id_profesor) ON studenti.id_stud = note.id_stud " +
"WHERE profesori.user_name = '" + user + "'";
i want to give a name to the result table so i can put it in a DataSet
dadapter.Fill(ds,"table name");
Thanks
|
|
|
|
|
You don't need to know the name to put the results into a dataset. Just look at the overloads available.
|
|
|
|
|
In SQL Server: What is "ntext"? What is it for? How to use?
It is difficult for me to understand. A example will help me better.
For example: I have a Web page. I need display the content of news,include texts that larger than data type of ntext for a column.
What must I do now?
Thanks!
|
|
|
|
|
From bol
ntext: Variable-length Unicode data with a maximum length of 2^(30 - 1)(1,073,741,823) characters. Storage size, in bytes, is two times the number of characters entered. The SQL-92 synonym for ntext is national text.
If your news content will always be less than 8000 characters you can use varchar or nvarchar. Otherwise you will have to use text, ntext or image datatype.
http://msdn2.microsoft.com/en-us/library/ms190258.aspx[^]
http://msdn2.microsoft.com/en-us/library/ms191262.aspx[^]
--
Don't take life seriously because you can't come out of it alive.
-Warren Miller
(From Monty2[^] bio)
|
|
|
|
|
I am trying to creat a function in SQL Server where it returns a the value of a column in a table where the column is passed as a parameter.
Below is the function where I want to return the value in the user table for column @field. Thanks for your help.
CREATE FUNCTION [dbo].[USER_RETURNCOLUMN] (@userid decimal, @field varchar(200))
RETURNS varchar(2000)
AS
BEGIN
DECLARE @RETURNVALUE varchar(100)
SELECT @RETURNVALUE = ''
SELECT @RETURNVALUE = @field
FROM USER_TABLE
WHERE USER_ID = @userid
RETURN @RETURNVALUE
END
|
|
|
|
|
If you ask me no chance to do this in a user defined function. You would need dynamic SQL with exec( @stmt ) and that is not allowed in UDFs. Can't you use a stored proc? You can use dynamic SQL there.
Regards,
Rainer.
Rainer Stropek
Visit my blog at http://www.cubido.at/rainers
|
|
|
|
|
i want to sort a table by string column
this column contains data in this format ddd/dddd (ex: 100/2006 or 6/2006)
so when i order the table by this column, it will sort like this:
1/2006
11/2006
111/2006
2/2006
22/2006
but i want to sort like this
1/2006
2/2006
11/2006
22/2006
111/2006
so, is there any why to sort like this on a vb.net application not in the database?
Faris Madi
Nothing Comes Easy (N.C.E.)
|
|
|
|
|
|
SELECT *<br />
FROM MyTable <br />
ORDER BY REPLICATE('0',8-LEN(mycolumn)) + mycolumn
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
i'm using SQL SERVER 2000 with .net 2003
my problem is when i connect to the other computer that has the database
it keep telling me "Login faild on Computername\Guest"
and i've installed the SQL SERVER 2000 on the other computer on mixmode authentication.
Why he want to login to Guest Account... while Guest account is off.
i'm using this connection string:
Me.SQLConnection_Search.ConnectionString = "packet size=4096; Trusted_Connection=true; Persist Security Info=true; SERVER= 192.168.0.1; User ID= sa; Password=sa;initial catalog=aqar; "
so where is the problem.
Faris Madi
Nothing Comes Easy (N.C.E.)
|
|
|
|