|
I don't know about your specific situation, but have you looked at using BULK INSERT or bcp (via xp_cmdshell)?
Regards,
Jeff Varszegi
|
|
|
|
|
Hi Geeks,
I am quite new to SQL Server.Well I have a problem..
Could someone help me ??
This is my Query:
sql="SELECT Id,Name, Age,City, AdmDate
FROM IP LEFT JOIN MDoc
ON IP.DoId=MDoc.DoId
WHERE AdmDate='11/15/2003'
ORDER BY IP_Id"
Now in the IP table there are records containing date values
i.e. AdmDate='15/11/2003' ;these date values r in small date format with precision to seconds.
Now I want All the records of a paticular date irrespective of their time Value.
-SimSan
|
|
|
|
|
I typically use
SELECT Id,Name, Age,City, AdmDate
FROM IP LEFT JOIN MDoc
ON IP.DoId=MDoc.DoId
WHERE AdmDate >= '2003-11-15' AND
AdmDate < DATEADD( Day, 1, '2003-11-15' )
ORDER BY IP_Id Of course, typically I use this is in a stored procedure where the literal date is replaced by a parameter, where using DATEADD makes a bit more sense.
|
|
|
|
|
This works fine...Thanks for the tip.
Well...I wanted to clarify if SQL Server treats
Dates in American Date format.If it does,why this date format ('yyyy-mm-dd') is in use.
-SimSan
|
|
|
|
|
Because I'm in the UK
SQL Server interprets literal dates in queries using the user's default locale - even in stored procedures, IIRC. You could write '10/11/2003' to be interpreted as October 11th, but if your user is using the English (UK) locale, it will be interpreted as 10 November.
"SQL Server evaluates datetime constants at run time. A date string that works for the date formats expected by one language may be unrecognizable if the query is executed by a connection using a different language and date format setting." Using Date and Time Data[^]
The ISO format yyyy-mm-dd is supposed to be supported in all locales with the same meaning.
On re-reading Writing International Transact-SQL Statements[^], it actually looks like you should use unseparated dates (format yyyymmdd) to ensure correct interpretation. So I've been getting it wrong.
|
|
|
|
|
Thanks again for your info..U've got it right!!!
-SimSan
|
|
|
|
|
You could use
SELECT Id,Name, Age,City, AdmDate
FROM IP LEFT JOIN MDoc
ON IP.DoId=MDoc.DoId
WHERE AdmDate BETWEEN '11/15/2003 00:00' AND '11/15/2003 23:59'
ORDER BY IP_Id"
|
|
|
|
|
Real simple problem but it is driving me nuts.
Create a table in SQL with two columns.
NameId and FullName
Make the NameId a primary Key.
Add a nameid and a fullname to the table.
Save the table as NameId.
Now using only the .net wizards for a windows forms project I do the following:
1. Create new project (windows forms)
2. Drag two textboxes onto the form.
3. Drag a button onto the form.
4. Drag a sqlDataAdapter onto the form which starts the wizard.
5. Connect to the sqldatabase for the table.
6. Allow it to create the sql statements.
7. Create the query using both fields.
8. Do not change the advanced settings.
9. Save the wizard.
10. Create a dataset using the NameId table.
11. Bind the two textboxes to the table fields via their respective properties.
12. On the window form events create an event for load.
13. Enter the fill method of the sqldataadapter:
this.sqlDataAdapter1.Fill(this.dataset1, "NameId");
14. Return to the design screen and create an click event for the button under its respective events.
15. In the code enter the following:
this.sqlDataAdapter1.Update(this.dataset1, "NameId");
now compile
my results are the form will display the one record, however when I change the fullname field to something else it does not update the sql NamId table...
What am I doing wrong...
Bruce...
|
|
|
|
|
I have a table1 where I have a dateentered and trantype.
I need to find the max(dateentered) and then based on trantype join table2 or table3. All data should be in one result. How do I do this?
|
|
|
|
|
You can't selectively join tables. You should probably use a union. Without knowing your table structure, here is a stab at it...
select max(dateentered), otherfields
from table1
join table2 on (table1.trantype = table2.trantype)
union
select max(dateentered), otherfields
from table1
join table3 on (table1.trantype = table3.trantype)
|
|
|
|
|
My more detail problem
CREATE TABLE [dbo].[table1] (
[TranID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[SID] [varchar] (10) NOT NULL ,
[GID] [varchar] (5) NOT NULL ,
[TranType] [varchar] (1)NOT NULL ,
[DateEntered] [datetime] NULL ,
) ON [PRIMARY]
CREATE TABLE [dbo].[Table2] (
[TranID] [numeric](18, 0) NOT NULL ,
[GID] [varchar] (5) NOT NULL ,
[SID] [varchar] (10)
) ON [PRIMARY]
CREATE TABLE [dbo].[Table3] (
[TranID] [numeric](18, 0) NOT NULL ,
[GID] [varchar] (5) NOT NULL ,
[SID] [varchar] (10)
) ON [PRIMARY]
Example1: I need select info from table1 and 2
Table1 Table2 Table3
TranID 1 1
SID 12 12
GID 1 1
TranType 'Y'
DateEntered '9/1/2003'
---------------
Example2: Infor from table1 and 3 (Maxdate)
Table1 Table2 Table3
TranID 1 1
SID 12 12
GID 1 1
TranType 'Y'
DateEntered '9/1/2003'
Table1 Table2 Table3
TranID 1 1
SID 12 12
GID 1 1
TranType 'N'
DateEntered '9/2/2003'
|
|
|
|
|
how to check for the access permissions of each user in a sql database?
can some one help me with a c++ code or this
ranjani
|
|
|
|
|
I am working on a new asp.net project using a Access 2000 database. I want to create some update queries in Access and then be able to call them using parameters to update certain fields. I have read some articles on how to do this using a SQL Server database, but I can't find any information on how to do this for Access. What I don't want to do is hard code any queries in code.
bgeroux
|
|
|
|
|
in Access .. on the left bar of the database window..
Select Queries then ->create Query in design view ->Close the show table screen -> right click ->choose SQL View
write your update query :
Update table1 set userName="bla bla" where ID=@MyID
@MyID is the value you pass to the query..(parameter)
you can declare it like this :at the beginning of the query (not required)
parameters @MyID long;
|
|
|
|
|
Here's an example[^] that demonstrates using stored queries in Access. It also briefly mentions some of the advantages of SQL Server over Access. Downloadable code and a sample database are available, as well.
"Your village called - They're missing their idiot."
|
|
|
|
|
Thank for responding so quickly. The example code is great, but this code is for using a ADO recordset and I am looking for a ADO.net solution. Is this possible?;)
|
|
|
|
|
I haven't worked with ADO.Net, as I can't afford the tools and my web host won't support it. But surely they haven't completely abandoned the architecture? Isn't there an equivalent to a recordset in ADO.Net? The key point in the article for me was how to structure the Command to Access; the details of how the platform accomplishes it should be fairly minor to implement. Just a guess though; as I said, I don't use ADO.Net yet.
"Your village called - They're missing their idiot."
|
|
|
|
|
A VB.NET console application (requires the database that Roger linked to above):
Imports System.Data.OleDb
Module Module1
Sub Main()
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim param As OleDbParameter
Dim rdr As OleDbDataReader
Try
conn = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=""courses.mdb"";" & _
"Persist Security Info=False")
conn.Open()
cmd = New OleDbCommand("qryStudentsOnCourse", conn)
cmd.CommandType = CommandType.StoredProcedure
param = cmd.Parameters.Add("@courseID", OleDbType.VarChar, 10)
param.Value = "C0450"
rdr = cmd.ExecuteReader()
While rdr.Read()
Console.WriteLine("{0} {1}", rdr("firstName"), rdr("lastName"))
End While
Finally
If Not rdr Is Nothing Then
rdr.Close()
End If
If Not cmd Is Nothing Then
cmd.Dispose()
End If
If Not conn Is Nothing Then
conn.Close()
End If
End Try
End Sub
End Module Hope this helps. Some people have reported that using the ODBC classes rather than OLE DB is faster in the current version of the framework (probably due to lower interop overhead for 'flat' APIs versus COM APIs).
|
|
|
|
|
This is exactly what I was looking for, thank you very much.
|
|
|
|
|
did any body know any equvalent to dbms_pipe (Oracle Pack) in SQL Server ??
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
It depends what you want to do with it.
If you want to return arbitrary out-of-band messages to the client, use PRINT . If you want to communicate between two server processes, you'll have to write that functionality yourself. You could do it as a set of extended stored procedures, but I would recommend using SQL Server just as a database server, and perform any required computations on the client.
This is basically a difference of philosophy between Oracle and SQL Server; Oracle says 'I am the master server and you are all my slaves', while SQL Server says 'Why can't we all work together?'
But seriously, SQL Server offers less support for building everything into the database. While it supports background operations, the only way 'foreground' operations (explicitly requested by a client) talk to background operations is through data stored in the database, unless you use some method of extending SQL Server.
|
|
|
|
|
Dear Mike,
Thank you for your replay, you have toled me to use print command is i would like to send out of band messages but the qustion is who can the cline catch this message , as if you like to send an alert to one of the clients after adding new data row in a table so you will create a triiger which will use print statement and how can the client (or many Clients catch it)?
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Ah, I see: you're trying to notify clients that some data has changed.
This can't be done in the current versions of SQL Server. The next version, codenamed 'Yukon', will support this feature.
At present, I would recommend periodically polling the table from the client. This technique will apparently be used by the ASP.NET cache management code in the next version of ASP.NET, codename 'Whidbey', due to be released next year (IIRC), for SQL Server 7.0 and 2000.
A PRINT statement is only received by the client whose commands caused the PRINT to be executed. In ADO.NET, this message is treated as an informational message of severity 0 and can be handled by handling the InfoMessage event of your SqlConnection . The same is true for classic ADO (the event is on the Connection object).
It looks like (and I'll admit I'm just trawling the documentation here) ODBC will return SQL_SUCCESS_WITH_INFO (as opposed to SQL_SUCCESS ) if a PRINT or a warning RAISERROR (severity 10 or below) occurs - you can then retrieve the message from SQLError . See also KB article 280109[^].
|
|
|
|
|
So Mr.Mike,
In this case i have create a table for sessions where any client can open a session by adding row to that table then i had create an extended exteneded procedure in c++ for SQL server which will send an alert on the TCP socket to all clients (executed on trigger) which had opened session to monitor a table so it is the best way to do it in this verssion of sql server 2000
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
SELECT Sum(Amount) as "Total Expenditures", Month(eDate) as "Month"
FROM Expenditure
GROUP BY Month(eDate)
ORDER BY Month(eDate)
Above is my current SQL statement. I would like to change it so that it would generate a table that shows zeros for months that have zero "Total Expenditures". Currently it only shows amounts for months that have
total > 0. I think I could do it once I get it into my datatable but the query would be nicer.
Thanks
"It has become appallingly obvious that our technology has exceeded our humanity."
- Albert Einstein (1879-1955)
"I think there is a world market for maybe five computers."
- Thomas Watson (1874-1956), Chairman of IBM, 1943
"640K ought to be enough for anybody."
- Bill Gates (1955-), in 1981
"Half this game is ninety percent mental."
- Yogi Berra
|
|
|
|