|
Still Getting Error
Please send me an Example with SQL code
Thanks
Sarfarj Ahmed
|
|
|
|
|
Ahhh, you need to ensure that all types are the same.
So if you have some int datatypes along with varchar or char you need to cast the int to a varchar. CAST(IntColumn as varchar(length))
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Hello,
I was trying to build an application using sql server 2000 and asp.net which would use real time resources, and; I have been facing an issue in which when two transactions occur at the same time, down to hh:mm:ss; then in that case a deadlock occurs and none of the transactions are completed. They remain pending unless u manually goto enterprise manager and change the seconds by making them +/-1
This issue can be reduced considerably if milliseconds can be used hh:mm:ss:fff. Is there a way to implement this?
Nikhil Joshi
|
|
|
|
|
Deadlocking does not occur because you have a datetime. It occurs because you have two resources which are locking each other.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I’m trying to make a loop that will select a count of all entries that have a "TimeIn" value on the date defined by an input parameter with an hour value between x & y.
So the first pass through the loop would select a count of all rows with a TimeIn between 00:00:00 and 01:00:00 on the selected day ...
The second pass will select a count of all rows with a TimeIn between 01:00:00 and 02:00:00.
finally it will return counts for each hour in the day.
This is my first attempt at loops in SQL so any push in the right direction would be much appreciated.
Thanks.
|
|
|
|
|
There is a better way to do this.
SELECT
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '00:00:00' AND '01:00:00') AS 'Time1',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '01:00:00' AND '02:00:00') AS 'Time2',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '02:00:00' AND '03:00:00') AS 'Time3',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '03:00:00' AND '04:00:00') AS 'Time4',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '04:00:00' AND '05:00:00') AS 'Time5',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '05:00:00' AND '06:00:00') AS 'Time6',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '06:00:00' AND '07:00:00') AS 'Time7',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '07:00:00' AND '08:00:00') AS 'Time8',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '08:00:00' AND '09:00:00') AS 'Time9',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '09:00:00' AND '10:00:00') AS 'Time10',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '10:00:00' AND '11:00:00') AS 'Time11',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '11:00:00' AND '12:00:00') AS 'Time12',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '12:00:00' AND '13:00:00') AS 'Time13',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '13:00:00' AND '14:00:00') AS 'Time14',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '14:00:00' AND '15:00:00') AS 'Time15',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '15:00:00' AND '16:00:00') AS 'Time16',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '16:00:00' AND '17:00:00') AS 'Time17',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '17:00:00' AND '18:00:00') AS 'Time18',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '18:00:00' AND '19:00:00') AS 'Time19',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '19:00:00' AND '20:00:00') AS 'Time20',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '20:00:00' AND '21:00:00') AS 'Time21',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '21:00:00' AND '22:00:00') AS 'Time22',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '22:00:00' AND '23:00:00') AS 'Time23',
(SELECT COUNT(TimeIn) FROM TableName WHERE TimeIn BETWEEN '23:00:00' AND '24:00:00') AS 'Time24'
FROM TableName
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
If you have SQL-Server then
select convert(varchar(13), TimeIn, 120) + ':00', count(*)
from MyTable
where TimeIn between @x and @y
group by convert(varchar(13), TimeIn, 120) + ':00'
order by 1 SQL is best for set operations. You can do loops and cursors but they tend to be slower and are harder to code.
Regards
Andy
|
|
|
|
|
Ohh so that is better than mine? Cool...
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
I sort of figured that it wouldn't work. It would be a shame for something to be easy once.
Does linking the SQL Servers only work if they are on the same machine? If not, could you give some keywords I can do some searching with. There's no reason to be humble about my ignorance now
Thanks for your help.
OT: I see you are from Glasgow. Any ideas for some good day trips for someone visiting? I've been there twice last year for work and will going back at least once this year.
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
BRShroyer wrote: Does linking the SQL Servers only work if they are on the same machine?
You can link any SQL Servers together.
BRShroyer wrote: could you give some keywords I can do some searching with
Your starter for 10: sp_addlinkedserver[^]
BRShroyer wrote: I see you are from Glasgow. Any ideas for some good day trips for someone visiting?
Loch Lomond, Isle of Arran (aka Scotland in Miniature), Edinburgh (45 mins on the train), Falkirk Wheel.
|
|
|
|
|
Hi guys,
Please help,I am having an issue with data access block connection to the database from my class library project.
using the data access block to connect to database works fine in my website project. but i try creating a separate class library project to connect to the database i now receive an error message.
"The value can not be null or an empty string."
and this is the code:
<br />
Database motomandb = DatabaseFactory.CreateDatabase();<br />
DbCommand motomandbCommand = motomandb.GetSqlStringCommand(query);<br />
<br />
using(DbConnection motomanConnection = motomandb.CreateConnection())<br />
{<br />
DbTransaction motomanTransaction = motomanConnection.BeginTransaction();<br />
try<br />
{<br />
rowsaffected = motomandb.ExecuteNonQuery(motomandbCommand, motomanTransaction);<br />
motomanTransaction.Commit();<br />
}<br />
catch (Exception e)<br />
{<br />
motomanTransaction.Rollback();<br />
}<br />
}<br />
thanks in advance
|
|
|
|
|
any one here for giving me help that i get a problem to store store jpg files in sql or oracle (blob).
please
i am student of ignou .
|
|
|
|
|
Please post the complete error / problem details.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
|
I am making an control which saves xls file in database attached by user. file size will be of 3 MB and there will be 3 such files. Can someone please help me and tell me how can i directly save the file in database rather then saving it in some location on server.
Ram shankar tripathi
Software Engineer
Telstra
Australia
|
|
|
|
|
I have the next problem: in the table with the primary key field "ID" (it is identity with automatic incrementation) when I delete row, the row isn't completely removed - the ID field remain (although it looks like row was removed) - and as a result, next created row has ID wich is equal to ID of previous deleted row + 1. How to delete row from table with autoincrement primary key correctly?
...fear makes people manageable...
|
|
|
|
|
When you have an identity column you do not get deleted id's back. If you delete all rows from the table and want to reset the identity back to a value you need to do this:
DBCC CHECKIDENT('TableName', RESEED, 1)
Hope that helps.
Ben
|
|
|
|
|
|
Noob question:
If I have several (4-5) computers with SQL Server 2005 Express on them, can they all access the same database file located on a remote/network drive? Would they be able to access it at the same time?
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
No.
SQL Server opens the file exclusively and controls it completely. Only one instance of SQL Server can open a database file. Also, the files must be on the same physical machine as the SQL Server.
However, you can link SQL Servers together so they can share the data. The SQL Server that owns the file will control all access to the data.
|
|
|
|
|
Hey everyone,
I am working on this project, mostly database driven.
this is what it is about:- The user interface is install on three computer in different location while the database is kept on another computer in a seperate location, which means all three computers has to connected to this sql server to enter and retrive data. That means if the server goes down.. neither of these location will be able to continue there work.
What i am thinking about now, is to install sql server on all three machine so that data is stored at each location and at the end of each day all the data from the three location would be uploaded or Synchronized to the main database.
Problem.. how do i get all three database to Synchronize with the main database? Do i have to hard code this to happen or is there a feature that does this in sql 2000...
your help would be highly appreciated...
thanks.
Nab
|
|
|
|
|
|
Hi, I am trying to generate a typed dataset with an xsd schema, but I seem to do it only half right.
In one application, I read my MySql database (4 data tables) into a simple dataset, I define the relations and I export it with the WriteXmlSchema method. This works fine.
Then, I import my newly created xsd file to another project, in which I want to create a typed dataSet. In this project, I'm able to view my schema, and when I right-click and select Preview DataSet, everything looks great, I have my 4 tables and all the Properties are shown.
However, when I select Generate DataSet and go write some code, I only have one table for which a FindBy method has been generated. No property is defined in my other 3 tables.
Can somebody please help me, this is driving me nuts!
Thanks!
-- modified at 10:27 Wednesday 14th March, 2007
|
|
|
|
|
Hi,
I am doing a project that involves Ms Access database connectivity in vb.net.I can do the insertion and updation of record by the code as mentioned below:
Imports System.Data.OleDb
Public Class Form2 Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim icount As Integer
Dim str As String
Private Sub Add_Click(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles Button2.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\emp.mdb;")
cn.Open()
str = "insert into table1 values(" & CInt(TextBox1.Text) & ",'" & TextBox2.Text & "','" &_
TextBox3.Text & "')"
'string stores the command and CInt is used to convert number to string
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
'displays number of records inserted
Catch
End Try
cn.Close()
End Sub
End Class
Updation of records
Me.BindingContext(ds, "Employee").EndCurrentEdit()
Me.da.Update(ds)
But I cannot do the saving and deletion of record.I would be very thankful if anybody can help me out in this difficulty.If possible plz provide me the code.
Thanking You.
Romana Sayed
|
|
|
|
|
Make sure that you have dataadapter update command specified. This might prevent updation using dataset
|
|
|
|