|
try this
select convert(varchar(10), getdate(), 23)+' '+convert(varchar(12),getdate(),14)<br />
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
A DateTime value is stored in no particular format, a format is only applied when the value is displayed.
|
|
|
|
|
Im returning an XML from a stored procedure using "FOR XML, XMLDATA". Is there any way to specify the name space to be returned? I want to return eg (xmlns="http://App.myapp") and not the default(xmlns="x-schema:#Schema1")
Thanks
|
|
|
|
|
|
Hello!
The uniqueidentifier produces an automated value and it is not acting likely PK in Access database. Therefore I decided to create a uniqueidentifier function which produces a unique value. I defined the first column as an uniqueidentifier column in my table and assigned char(30) instead of uniqueidentifier newID() where I assign produced value.
My question is: is it still mandatory to define this column as uniqueidentifier NEWID() column and then later on assign the produced value to this column as shown example below or can I simply define a column which will be used as an uniqueidentifier column with a definition of Char(30) and then I assign the produces value to this column ?
What would be the prons and cons?
Regards,
<br />
<br />
DECLARE @GUID uniqueidentifier<br />
SET @GUID=NEWID()<br />
INSERT Item VALUES(@GUID,ProducedIdentifier)<br />
<br />
<br />
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
I'm not sure I follow you.
To use a Guid, use the uniqueidentifier datatype.
To have it created automatically, set RowGuid to Yes.
To create the Guid separately, set RowGuid to No.
If you don't want to use Guid, don't use the uniqueidentifier datatype.
Don't use character data as a primary key (or at least very rarely).
What problem are you having?
|
|
|
|
|
Whenever I run a particular test, i don't get all of the data. But when I run the test in debug, I get all of the data. The test is independent of other tests. The only thing in common is that they all talk to the database (ms access database). Also, I get all of the data when I run all of the tests. Any idea on why this is happening and how I can resolve this problem?
Thank you,
Prateek
|
|
|
|
|
Can you describe more technically your problem?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
After the data gets added to the database, I read and print out the data in nUnit's console from the database. There are times when I can't read all of the data from the table. e.g. if the table has 5 rows, it will sometimes show me only 2 rows. And then there are times, when it would print out incorrect values from the data e.g. if a column has an integer value of '2', it will print out '0'. My guess for this would be that it wasn't able to read the data from that particular column.
What other type of information would you like to know?
|
|
|
|
|
I need to know the ID of a last inserted record. The problems is, that I use VS generated dataset and table adapter, so the classic "SELECT @@IDENTITY" is not working.
I also tried to use "SELECT IDENT_CURRENT('tablename')", but for some reasons it crashes at the runtime, saying that function IDENT_CURRENT is not recognized, or something like this.
|
|
|
|
|
This query select top 1 id from tablename order by id desc will not be choice for you?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
yeah, it worked. Thank you very much. Still, I have a question: isn't it the same as choosing the maximum ID?
|
|
|
|
|
makumazan84 wrote: Thank you very much.
No problem.
If ID value is increase-able always then we can use max function to get maximum value of ID.
example: select max(id) from tablename
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
This only works in a single user environment - otherwise someone else could insert before you run the select. Also, this relies on id being the prmary key, otherwise you should select the max(id) - bad practice to rely on any ordering unless specified.
Do't know what the answer is though, I nvere use tableadaptors etc, there isn't enough control over transactions etc for the sort of systems I usually work on.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks for your information.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
select max(id) from mytable should be enought but...you may need to use a lock. Read about it i don´t know much about it!
If it´s a read/report procedure (you don´t delete or edit anything) there´s no problem using select max(id )from mytable, otherwise you must use somekind of lock!!!
To prevent users to edit same thing same time
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
hi to all,
i am making an application using windows mobile 5.0 sdk and connecting to sql server mobile edition ........i made the .sdf file using sql server management studio and kept in my application directory ............
string strAppWorkingDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
string connstr = "Data Source=" + strAppWorkingDir + @"\" + "sample.sdf; Persist Security Info=False;";
string connstr = "Data Source=C:\\Documents and Settings\\IT\\sample.sdf; Persist Security Info=False;";
string connstr = "PROVIDER=Microsoft.SQLServer.OLEDB.CE.3.0; Data Source=C:\\Documents and Settings\\IT\\sample.sdf";
string connstr = "Data Source =." + @"\" + "sample.sdf;" ;
SqlCeConnection conn = new SqlCeConnection(connstr);
SqlCeDataAdapter adapter = new SqlCeDataAdapter("select * from table1",conn);
DataSet dst = new DataSet();
adapter.Fill(dst);
textBox3.Text = dst.Tables[0].Rows[0].ItemArray[0].ToString();
i have tried all these connection string but most of the time i am getting an error :-
An unhandled exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
Additional information: The database file cannot be found. Check the path to the database. [ File name = .\sample.sdf ]
although it is working when connect with wizard ...............................as it keep connections in .xsd........
please can anyone help me out how to connect to .sdf file..............................................
Thanks & Regards
Manish Singhal
Software Engineer
Maxworth systems(Delhi)
|
|
|
|
|
First, of all your question belong to 'Mobile Development' board.
Second, check this link[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
hi,
thanks for ur reply i sorry i must had post it there .............................those strings r not working ..................................can please me some peace of code or application sample ...........
thanks
Thanks & Regards
Manish Singhal
Software Engineer
Maxworth systems(Delhi)
|
|
|
|
|
hi i ma using a query like to select country code using between query cause ip
if im using this query i will fetch value sometime but i will display time out expired error some time.
to over come this problem what can i to do
can share your ideas with me
my query is
SELECT countryShort FROM IPCITYLATLONGISP WHERE '3678433939' between ipFrom and ipTo
with regards,
bretto
|
|
|
|
|
Try to optimize your query.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Have you considered putting an index on this column (you need to consider that while it may speed up your query, it might also slow down your inserts).
|
|
|
|
|
Besides optimizing your query (perhaps by indexing the column) you can increase the query timeout in your code.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Can anyone help me here? i need to use this method
declare @season as varchar(4)
set @season = '2004'
declare @sql1 as varchar(max)
declare @sql2 as varchar(max)
declare @sql3 as varchar(max)
select @sql1 = 'create table driver_'+@season+'(id int, f_name varchar(50),l_name varchar(50))'
exec (@sql1)
declare @id int
declare @f_name varchar(50)
declare @l_name varchar(50)
set @id = 123
set @f_name = 'lewis'
set @l_name = 'hamilton'
select @sql2 = 'insert into driver_'+@season+' values(@id,@f_name,@l_name)'
exec (@sql2)
select @sql3 = 'select * from driver_'+@season
Error msg: Msg 137, Level 15, State 2, Line 1
Must declare the scalar variable "@id".
Not declared he says!!!
nelsonpaixao@yahoo.com.br
|
|
|
|
|
here it is:
<br />
declare @season as varchar(4)<br />
set @season = '2004'<br />
declare @sql1 as varchar(255)<br />
declare @sql2 as varchar(255)<br />
declare @sql3 as varchar(255)<br />
select @sql1 = 'create table driver_'+@season+'(id int, f_name varchar(50),l_name varchar(50))'<br />
exec (@sql1)<br />
<br />
select @sql2 = 'declare @f_name varchar(50)<br />
declare @l_name varchar(50) declare @id as int set @id = 123 <br />
set @f_name = ''lewis'' <br />
set @l_name = ''hamilton'' insert into driver_'+@season+' values(@id,@f_name,@l_name)'<br />
exec (@sql2)<br />
select @sql3 = 'select * from driver_'+@season
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|