|
how to generate primary keys automatically in SQL Server2000 using enterprise manager
|
|
|
|
|
You have to do it yourself. It's not access. Insert a column, right click it and click Set Primary Key. You may also want to make the column autoincrement also.
ChrisB
|
|
|
|
|
Hi All
I just wanted to ask which is more optimal in terms of time & complexity.
1. Returning more than once to the database to retrieve some data
or
2. Getting all the data once & declaring a table at the database to store this data then getting the rows I want from this table & returning it as a string
Thanks a lot
Happy
|
|
|
|
|
i have pb connecting to remote sqlserver using asp.net the connection string i used
is
Dim sqlconn As SqlConnection = New SqlConnection("server=155.155.55.5;user id =try;password=try; database=db1")
the error i get is "sqlserver does not exist or access denied"
i check the authentication its correct...
i am not able to create obdc connectivity also for it ...
the sqlserver2000 is newly installed and just database is created.no other configurations done to database or tables.
thanks for help in advance .
waiting for your reply...
|
|
|
|
|
If the SQL 2000 installation includes SP3, then the default install disabled SQL authentication.
|
|
|
|
|
thnks for reply
but i have enabled the sql authentication in the installations steps..
i have not updated the sqlserver2000 evaluation edtition as it asked after installation to upgrade it to solve compatibility issue with win20003 r2 server .does this could have been the problem with not connecting..
the greatest thing is my application worked on live server which is already configured but not running this development server...
|
|
|
|
|
Hi all,
For Windows Application,
I have more than one DataTable in a Dataset,
I want to show different columns from diferent DataTable in a row.
For Eg:
DataTable 1: contains Fiels like 1C1,1C2,1C3
DataTable 2: contains Fiels like 2C1,2C2,2C3
DataTable 3: contains Fiels like 3C1,3C2,3C3
I want to show the record in DataGridView in one row like,
1C1,1C2,1C3,2C1,2C2,2C3,3C1,3C2,3C3 use of Binding
And also I want to update all the dataTables back to DataBase.
How to achieve this..
Thanks
raja
|
|
|
|
|
Hi there
guess u should use the join method for the three datatables and then display the results after string manipulation or u need to read the values by using a loop and append the values to a stringBuilder (remember to import the System.text)
Hope that it helps
Best Regards
3ala2
|
|
|
|
|
I am trying to add data in databse by useing this code but i dont know wnow why it is not craeting MyTable it is creating Database.mdb but table is not cretaing why? is the code is incorrect or you can help me to correct my code?I have not done here the ODBC connection
<br />
CDaoDatabase database;<br />
CDaoRecordset recordset(&database);<br />
CString lpszFile = "c:\\Database.mdb";<br />
database.Create(lpszFile);<br />
database.Open(lpszFile);<br />
CString SqlCmd = "CREATE TABLE MYTable (MarketNo VARCHAR(2),MarketName VARCHAR(8),Bid VARCHAR(10),Ask VARCHAR(10),MarketState VARCHAR(2))";<br />
database.Execute(SqlCmd);<br />
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM MyTable",0);<br />
database.Execute("INSERT INTO MyTable(MarketNo)");<br />
database.Execute("INSERT INTO MyTable(MarketName)");<br />
database.Execute("INSERT INTO MyTable(Bid)");<br />
database.Execute("INSERT INTO MyTable(Ask)");<br />
database.Execute("INSERT INTO MyTable(MarketState)");<br />
recordset.AddNew();<br />
recordset.SetFieldValue("MarketNo","a");<br />
recordset.SetFieldValue("MarketName",Market);<br />
recordset.SetFieldValue("Bid","b");<br />
recordset.SetFieldValue("Ask","c");<br />
recordset.SetFieldValue("MarketState","d");<br />
recordset.MoveNext();<br />
recordset.AddNew();<br />
|
|
|
|
|
I'm having trouble coming up with a query in SQL Server 2000. Trying my best to sum it up in one sentence; I need a result set that for every EventID/StartDate that exists in tblEvents, I need all StartDates within x days to have a minimum sequential, unique number starting at 1. Now I'll go into some more detail and possibly confuse everyone.
What I have is a table of events that to simplify this question include only an EventID and an StartDate field. What I need to do is for each event, find the other events that occur within x days after the event in question. I then need to number the events starting at 1 so that each eventB that occurs within x days of EventA has the minimum number different from any events from the past x days. I know I just sucked at putting it in words so I'll give an example.
Here is what my idea of the end result table should like if x=2. The source table is basically the same thing minus the Num column.
tblEvents
------------
EventID Date Num
1 10/1/06 1
3 10/2/06 2
7 10/1/06 3
4 10/4/06 1
6 10/10/06 1
2 10/20/06 1
5 10/21/06 2
Here's a quick diagram I made (I know it's ugly and not to scale) which hopefully helps you understand what I need better. Basically, I will be drawing a timeline using vml and each item is going to have text next to it so I need items to be staggered if they are on the same day or close to each other so that things don't overlap. I also need to minimize the vertical space it takes up which is why num needs to get back to 1 as soon as it can instead of just putting each event on its own line. The "num" column will tell me what row to put the item in.
http://i10.tinypic.com/43pxycj.gif
The following query gets me closer I think but it has a few problems and could be the wrong approach completely. I need this to work in SQL Server 2000 and I know that Row_Number and also Over() I think are both SQL Server 2005 only which is one problem with what I've come up with so far. Also, the partition I use has a separate value for the mirror of items (eg. EventID 7 should not be on row 1). Any tips or thoughts would be appreciated.
SELECT E1.EventID AS E1_EventID, E1.StartDate AS E1_StartDate, E2.EventID AS E2_EventID, E2.StartDate AS E2_StartDate, DATEDIFF(day, E2.StartDate, E1.StartDate) As Diff, ROW_NUMBER() OVER(PARTITION BY E1.EventID ORDER BY E1.StartDate, E1.EventID) FROM tblEvents AS E1 LEFT OUTER JOIN tblEvents AS E2 ON E1.EventID < E2.EventID AND ABS(DATEDIFF(day, E1.StartDate, E2.StartDate)) <= 2
Thanks for any help!
Tom
|
|
|
|
|
Hello,
I need to load the last N records from a table.
The last N records are determined by date.
And I want N to be a parameter in the Query.
How can I do this?
I allready have a Query. The only thing I am missing is that part.
SELECT web_News.ArticleDate, web_NewsLocalized.ArticleTitle,
web_NewsLocalized.ArticleText
FROM web_News INNER JOIN web_NewsLocalized ON
web_News.ArticleId=web_NewsLocalized.ArticleId
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture]);
Thanks,
Miguel
|
|
|
|
|
If you are using SQL Server 2005, there is a simple way:
<br />
SELECT TOP(@N) web_News.ArticleDate, web_NewsLocalized.ArticleTitle,<br />
web_NewsLocalized.ArticleText<br />
FROM web_News INNER JOIN web_NewsLocalized ON<br />
web_News.ArticleId=web_NewsLocalized.ArticleId<br />
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture]) ORDER BY web_News.ArticleDate DESC;<br />
|
|
|
|
|
Hi,
I am using Access. The top (@N) is not working. I get an error when trying to save the Query.
I have been looking in internet but I can't find the solution.
I also tried [@N] but no luck.
Any idea?
Thanks,
Miguel
|
|
|
|
|
<br />
SELECT web_News.ArticleDate, web_NewsLocalized.ArticleTitle,<br />
web_NewsLocalized.ArticleText, (SELECT COUNT(*) FROM web_News AS B WHERE B.ArticleDate>=A.ArticleDate) AS RowNumber<br />
FROM web_News AS A INNER JOIN web_NewsLocalized ON<br />
web_News.ArticleId=web_NewsLocalized.ArticleId<br />
WHERE ((web_NewsLocalized.ArticleCulture)=[@Culture] AND RowNumber<=@N) ORDER BY web_News.ArticleDate DESC;<br />
I am not sure wheather it works, I've not tested yet, but just try it anyway. The performance will be a big problem
|
|
|
|
|
I am attempting to use a reportviewer control in a web app to access a working RS report stored on a Report Server. The report displays correctly when I access it from the application using a URL with a Response.redirect.
I have read the article "Integrating Reporting Services 2005 Into a Web Application" on this site, and have stepped through the instructions for setting the properties, etc. When I try to execute the report, I can see the "Report Being Generated" very briefly (sometimes), then I get the message "Execution '2fxr4rrhj1nah355k5vnbs45' cannot be found".
Any clues?
catmom
|
|
|
|
|
I have the following table field name = "ordDate" which holds DateTime for orders. Ive tried the query below but without success. I need to get all information based on the passed "DateTime". any help will be apreciated
select *
from order
WHERE ord_date = CONVERT .ToDateTime('14/09/1994')
|
|
|
|
|
<br />
select *<br />
from order<br />
WHERE ord_date = @ComparedDate<br />
@ComparedDate is a DateTime parameter, you have to provide it's value from caller.
<br />
Dim cmd as new SqlCommand(select * from order WHERE ord_date = @ComparedDate", conn)<br />
cmd.Parameters.Add(new SqlParameter("@ComparedDate", SqlDataType.DateTime)).Value=Convert.ToDateTime("14/09/1994")<br />
Dim reader as SqlDataReader=cmd.ExecuteReader()<br />
...<br />
|
|
|
|
|
How do I Commit changes that I edit in a DataGridView that I have used databinding from my SQL Server?
_____________________________
...and justice for all
APe
|
|
|
|
|
Hi,
Is there a way to restore a database with using .bak file? Either from "data file" or "log file"? I got a copy of those from the Microsoft website but how to restore this?
Many thanks.
|
|
|
|
|
Create a new database of the same name.
Then restore the bak file over the newly created database. The thing you need to watch for is that the bak file stores the file location of the log and data when it was backed up. You will need to change this to the actual file locations on your computer.
|
|
|
|
|
Hi,
I executed a stored procedure through VS2005 and the true boolean coloumsn came backs -1, and false as 0. Why didn't it display 1 for the true coloumns?
Regards,
ma se
|
|
|
|
|
In this case, the database stored boolean as a signed type (integer for example). All bits will be 1 for true and 0 for false. If first bit is 1, then that value is a negative one.
|
|
|
|
|
It has been a very frustrating effort attempting to find the root cause of this problem. I have searched the web sites and there is no definitive explanation. Likewise, this same message has been posted on Microsoft's SQL Server forum. There have been many viewers, but no responders.
We are running a Visual Studio C++ application using Sql Server / ODBC. SQL Queries are formatted and exceuted from the C++ code.
This particular SQL Error occurs about once every few months. Since the time of the last error, I added additional debug statements which log the exact format of the SQL Query that is being executed.
This is the SQL query that just failed.
SELECT * FROM [LaneInventory] WHERE (LaneInventory.LocationName = 'LANE_06');
The query that failed is executed hundreds of times within a 24 hour period every day, with the only exception being the location name changes in the query. The same exact query identified above was executed successfully about 15 minutes prior to this failure.
The SQL Exception message is very misleading.
I am wondering if SQL Server gets into a confused state every one in a while, or maybe it is a problem with the ODBC driver. The C++ application code is running on Windows 2003.
AbbyDabby
|
|
|
|
|
I'm not expert on databases, but the error is "Attempt to open a table failed"...so is it possible that your problem is caused by two people accessing the same file at the same time...one of them failing to open it because the other one had it locked? Or is there some other scenario where that file could be locked or unavailable for any reason?
|
|
|
|
|
Hi,
I currently have a DataGrid which retrieves the Surname of a user into one of the columns using an SQL View.
I would like to have the SQL View retrieve both Surname AND Forename.
Here's the current view:
SELECT tblProject.inProjectID, tblProject.vchProjectName, tblUser.vchSurname, tblProject.dtStartDate, tblProject.dtCompletionDate
FROM tblProject INNER JOIN
tblUser ON tblProject.inProjectManagerID = tblUser.inUserID
The view allows the display of the Surname. I would like to display "Surname, Forename" i.e. "Smith, John"
I used the following query for application on a DropDownList:
"SELECT tblUser.inUserID, tblUser.vchSurname + ', ' + tblUser.vchForename AS ForenameANDSurname FROM tblUser ORDER BY tblUser.vchSurname"
I just can't seem to fit it into the View
Any Ideas?
Thanks
|
|
|
|