|
I presume it looks up the various sys* tables (e.g. sysobjects & syscolumns) to find out what is in the database and create a script based on that.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I have a small c# application that connects to a sql server (msde, 2000 or 2005). At a certain point I scheduleld a database backup to a file like this :
BACKUP DATABASE myDatabase TO DISK = 'c:\test folder'
Nothing wrong if the server is on the computer that runs tha small application, but if the server is on a remote computer the file is saved on that one instead on the one that runs the application.
How can I save the file on the computer that acceses the sql server (na- how can I make the server interact upon backup-restore with an other computer over the network)?
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Vlad Stanciu wrote: Nothing wrong if the server is on the computer that runs tha small application, but if the server is on a remote computer the file is saved on that one instead on the one that runs the application.
That is correct because the command is running on the remote server so all disk access will be as seen from the SQL Server, not your local machine.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
So how can I connect to a remote server and backup a database localy?
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
You don't. You backup on the remote machine then copy the file across the network.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Thanks for your answer!
Now I have another question, kind of offtopic... why didn't MS implemented the functionality to backup batabases to the terminals (remote pc's).
Security? I mean if you are able to backup a database you are able to querry it too, so there is noting to protect...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Vlad Stanciu wrote: Security? I mean if you are able to backup a database you are able to querry it too
Not necessarily. You can assign a user account the the db_backupoperator role which permits only backing up the database (assuming no other permissions are granted).
Storing the backups on the local machine only means that you have to provide additional security rights in order to get the backup off the machine in order to restore it elsewhere.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
One of our projects is using Enterprise Library for data access (i.e. Data Access block). I looked at the code and don't see what's the advantage of using Data Access Block...
But one big advantage I is, you don't need to "Close" connection.
Personally, I find NHibernate much more helpful in minimizing data access chores...
Norman Fung
|
|
|
|
|
Right Now I have this code:
Private Sub add()
Dim firstvalue As String = txtName.Text
Dim secondvalue As String = txtSurname.Text
Dim conn As OleDbConnection = New OleDbConnection(strConnection)
Dim cmd As OleDbCommand = New OleDbCommand
cmd.Connection = conn
cmd.CommandText = "INSERT Into tblMembers(Name, Surname) VALUES (?,?)"
cmd.Parameters.Add("Name", firstvalue)
cmd.Parameters.Add("Surname", secondvalue)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub
But an error is occuring telling me this:
Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query.
What do you thing this is?? Help me please!!
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
hi i want to make an select statment that contains some data, that is
SELECT Name,ID, Sname,Schools from student
imagine that this table have one student have the same ID and same name but i need the last one how can do that while there are no Primary keys .
can i use grouped by Name alone or i should make a grouped by name,ID,..
Amarni
|
|
|
|
|
Amarni wrote: imagine that this table have one student have the same ID and same name but ... there are no Primary keys
So what is ID if not the primary key?
Amarni wrote: i need the last one
What do you mean by "the last one"? Databases contain sets of data there is no implied order of anything in the database. If you want to make something ordered then it has to be ordered on a column or columns. Which column defines the order?
Amarni wrote: can i use grouped by Name alone or i should make a grouped by name,ID,..
GROUP BY will allow you to aggregate the other columns based on the column or columns you are GROUP ing BY . That means you will no longer be able to access ID , Sname , Schools other than through an aggregation function such as MIN() , MAX() , SUM() , AVG() etc.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I use a table named FDetails with 4 text fields and a datetime field named date in MSaccess
when insert values into table ising ado recordset obj I receive some syntax error
recordset->Open("INSERT INTO FDetails(name,path,duration,volume,date) VALUES('hello','location','duration','vol','12/12/2000')",connection.GetInterfacePtr(), ADODB::adOpenForwardOnly,ADODB::adLockReadOnly, ADODB::adCmdText);
any one know inserting date into table
|
|
|
|
|
I have a question SQL Server cursor question
I have a table, “clients”. I want to create a cursor to select and iterate through each client in the database. Obviously, that will lock the “clients” table. Fine. But if I involve another table to do a filter (in the where clause, to reduce the result set) does that lock both tables and just the “Client” table?
Thanks in advance,
Frank
www.TheOpenSourceU.com
|
|
|
|
|
Also, it is important to note that the table i'd be using is a constantly used table (it touches almost every thing)
Thanks again,
Frank
www.TheOpenSourceU.com
|
|
|
|
|
Jawz-X wrote: I want to create a cursor to select and iterate through each client in the database. Obviously, that will lock the “clients” table.
It will not obviously lock the clients table.
SQL Server Books Online:
Cursor Transaction Isolation Levels
The transaction locking behavior of a specific cursor is determined by combining the locking behaviors of the cursor concurrency setting, any locking hints specified in the cursor SELECT, and transaction isolation level options.
Microsoft® SQL Server™ 2000 supports these cursor transaction isolation levels:
Read Committed
SQL Server acquires a share lock while reading a row into a cursor but frees the lock immediately after reading the row. Because shared lock requests are blocked by an exclusive lock, a cursor is prevented from reading a row that another task has updated but not yet committed. Read committed is the default isolation level setting for both SQL Server and ODBC.
Read Uncommitted
SQL Server requests no locks while reading a row into a cursor and honors no exclusive locks. Cursors can be populated with values that have already been updated but not yet committed. The user is bypassing all of the locking transaction control mechanisms in SQL Server.
Repeatable Read or Serializable
SQL Server requests a shared lock on each row as it is read into the cursor as in READ COMMITTED, but if the cursor is opened within a transaction, the shared locks are held until the end of the transaction instead of being freed after the row is read. This has the same effect as specifying HOLDLOCK on a SELECT statement.
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Thank you for that information. So, the answer to my question is that, in fact, neither table will be locked.
So, I should probably know this, but please enlighten me and save me some research (I don't use cursors very often, I think I did one once). But why then are cursors to be considered a last resort? Is it simply the amount of resources that they use on the DBMS?
Thank you,
Frank
www.TheOpenSourceU.com
P.S. I like your quote.
|
|
|
|
|
Jawz-X wrote: But why then are cursors to be considered a last resort?
Because they are increadibly slow. I once saw a question on this forum complaining that the code was taking too long (it was using cursors). I suggested a better query to use without cursors and the operation took around one second to complete.
Some things cannot be solved without cursors which is why they exist. But oftentimes the code can be re-written without cursors.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
i m not able to execute ado.net application with sql server
database .
i m getting error as login failed.
i want to use sql server with my asp.net application.as i didnt install sql server in my p.c i dont know user name and pwd.
plz help
|
|
|
|
|
lucky1234560 wrote: i want to use sql server with my asp.net application.as i didnt install sql server in my p.c i dont know user name and pwd.
It is recommended to use Windows Authentication to access the SQL Server. It may be possible that the person who set up SQL Server on your machine did that. Why not speak to them about how they set up SQL Server on your machine? It would seem the most sensible first step.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Hello,
It's surely a stupid question, but I have a problem:
I have two tables like A with field´s number and amount and a table B with number and name.
Now I will have a join like 'SELECT ... form A, B where A.number = B.number - but I need the summary of 'amount', even if there does not exist an entry in table B. Is this possible with SQL??
Maiy thanks, Gerhard
|
|
|
|
|
It sounds like you are talking about a JOIN. If you want all of the data from the "left" table even if it doesn't match your SQL would look something like this:
"SELECT amount FROM A LEFT JOIN B ON A.number=B.number"
Or maybe this site could explain it better:
http://www.w3schools.com/sql/sql_join.asp[^]
|
|
|
|
|
Very many thanks for your reply. It's a wonderful help for me. But I have a secon qustion . The solution is great and it works, but can I do it with more than one table?
Someting like: A.numnber1, A.number2, A,amount WHERE A.number1 = B.number AND A.number2 = C.number'.
I have a table with accounting-sentences and there are accounting-numbers, cost-center-numbers and so on. And I want to give the numbers a name (which are stored in different tabels) without loosing the amount of 'value' in table 'accounting-sentences'
Many thanks again, your help was wonderful
|
|
|
|
|
Hello Kschuler,
I found how to do it with more tables. I tried a little bit with the enterprise manager. But i would not have been able to find it without your help. So again many thanks , ciao, Gerhard
|
|
|
|
|
We are using XML to pump data into a SQ: Server 2005 database. We pass an XML document into a stored procedure, the stored procedures chunks out the data and inserts it into the appropriate tables. Fine. Works great, easy to maintain, excelent performance. Here's the problem. One of the columns we are pushing data into is of data type text and the .value fuction of the XML node does not support conversion of a node's data to the 'text' data type. For example:
CREATE PROCEDURE as MyProcedure @myData xml<br />
BEGIN<br />
INSERT INTO MyTable (FirstName, LastName, Notes)<br />
SELECT<br />
MyNode.value('FirstName[1]','varchar(50)'),<br />
MyNode.value('LastName[1]','varchar(100)'),<br />
MyNode.value('Notes[1]','text')<br />
FROM @myData.Notes('Person') as R(MyNode)<br />
END
The problem is with the notes field. The cast to the data type text fails with the following error:
The data type 'text' used in the VALUE method is invalid.
The workaround thus far has been to use varchar(8000), but it will result in truncation if the data is too long.
Any ideas?
Jim Conigliaro
jconigliaro@ieee.org
|
|
|
|
|
Try varchar(MAX) instead of text .
|
|
|
|
|