|
The_Server wrote: Does anyone know any good tutorials or books.
SQL Server Books Online has many examples of how to use each of the available commands and procedures.
|
|
|
|
|
hi,
I prefer http://sqlzoo.net
where one can learn by practising (online)
(explanation, examples and exercise)
|
|
|
|
|
Moving data from file database to sql and questions came up as to whether use of user defined types was best practice or not. What are pros and cons? Do you use them or not and why?
Will also be using these types as parameters from C# code. So welcome any specific comments regarding impact there.
Thanks,
Matt
|
|
|
|
|
I am trying to return only the first 10 records in sql code that has a where clause. here is my current code. Any help is appreciated.
sqlQuery = "SELECT TOP 10 PTXADDR, ZIP, X_COORD, Y_COORD, PARENT FROM JOB.PTXGIS WHERE"
sqlQuery = sqlQuery & " PTXADDR LIKE '" & addr & "%'"
|
|
|
|
|
lavell wrote: I am trying to return only the first 10 records in sql code that has a where clause. here is my current code. Any help is appreciated.
In terms of getting the first 10 rows, I don't see a problem with your code.
In terms of security, you have a great big hole waiting to be exploited. You would be better reading about SQL Injection Attacks and Tips on How to Prevent Them[^]
|
|
|
|
|
sqlQuery = "SELECT TOP 10 PTXADDR, ZIP, X_COORD, Y_COORD, PARENT FROM JOB.PTXGIS WHERE"
sqlQuery += " PTXADDR LIKE '" + addr & "%'"
I just have replaced the '&' to '+'
|
|
|
|
|
It would be better if he didn't inject the value at all. That injection of the address opens a potentially big security hole.
|
|
|
|
|
can't we use the top keyword??
Gautham
|
|
|
|
|
Select top 10 field1 from table1 where field1--Some condition order by field1
Try this
|
|
|
|
|
Hi
using SQL 2000
i created a table (let - TA) and its view (sel * from TA) as VA
after creating the view, i added one column to TA
but the view is not showing it. the view must have to rebuild,
in sysColumns it doesn't shown the new col name in view.
any easy method there have innorder to rebuild it.
Thanks in advance
panal
|
|
|
|
|
panalprasad wrote: any easy method there have innorder to rebuild it.
Use ALTER VIEW to recreate the view.
And, it is considered better practice to actually specify the columns you want to use. Only use SELECT * for quick-to-write ad hoc queries.
|
|
|
|
|
If there is a possibilty that the master table changes frequently go for cursors instead of views...
Gautham
|
|
|
|
|
gauthee wrote: If there is a possibilty that the master table changes frequently go for cursors instead of views...
How would cursors solve the problem?
|
|
|
|
|
hai everybody
Am using sqlserver2000 as my back end. i want to combine 5 tables in a view and then got report from it. Is it possible? Already am combining 2 tables in a view. it was working fine. one table is master it has a composite primary key all the other containing same as a foreign key and also they have thier own primary key(Serial no)
Please Help me
|
|
|
|
|
Then just add the joins to the SELECT statement used to define the view. e.g.
SELECT *
FROM TableA
INNER JOIN TableB ON TableA.Key = TableB.ForeignKey
INNER JOIN TableC ON TableA.Key = TableC.ForeignKey
-- etc...
|
|
|
|
|
Hi,
I have a table named "FirstNames", "LastNames" and "Main". I want to enter data into the First and LastNames tables and then the identity number must be added to the Main.
I know it looks something like this but I cannot get the values into the main table.
Create Procedure dbo.Test
(
@F_FirstName varchar(20)
)
As
Insert Into FirstNames
(
F_FirstName
)
Values
(
@F_FirstName
)
Select Scope_Identity()
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
I'll let you fill in the gaps.
-- Declare a variable to hold the id
DECLARE @FirstNameID int
...
-- Get the ID after inserting the FirstName row
SELECT @FirstNameID = SCOPE_IDENTITY()
...
-- Insert the ID into the main table.
INSERT INTO Main(FirstNameID) VALUES(@FirstNameID)
|
|
|
|
|
5+7
5&7
what is the output
plz let me know
|
|
|
|
|
ravikiranreddydharmannagari wrote: 5+7
5&7
what is the output
plz let me know
SELECT 5+7
Result: 12
SELECT 5&7
Result: 5
+ is an addition operation
& is a logical AND operation
|
|
|
|
|
I am using SQL Server 2000 reporting services.I created a report in VS.net 2003.Report is showing in preview pane properly.But when i press start it gives a messege "No Reprot Server was found at http://localhost/ReprotServer".
Is reprot server required for the reprot.whats other alternative to show the report on web browser?
|
|
|
|
|
Please help...I think I'm losing my mind.
I'm using an OleDB connection in C# to connect to a database. The table I'm trying to access tracks user session information, including the date & time of logging in and primary key of the session. I start to run into problems when the user has logged in over 68 times.
Here is the section of code:
int LastLoginRow = userDS.Tables["UserSessionInfo"].Rows.Count - 2;
sring LastLoginDateTime = userDS.Tables["UserSessionInfo"].Rows[LastLoginRow]["SessionDate"].ToString();
I checked, and it does accurately tell me what the LastLoginRow is (i.e. 90). However when it goes to grab the SessionDate information, it ALWAYS grabs row 68.
Before it gets to row 68, it works fine. Does anyone know what is going on?
~~~~~~~~~~~~
Over-worked, under-paid, glorified "secretary"
|
|
|
|
|
The code looks OK. Might help to see the query.
Other than that, maybe all the rows after 68 have the same value in SessionDate?
Perform the query with some other tool and see what you get.
|
|
|
|
|
Here's some more information I've come across. There are two tables in my database, UserInfo & SessionInfo and they are connected through the field UserID, with a one-to-many relationship. When I look at the SessionInfo table alone, the sessions look as they're supposed to, the SessionPkey is ordered correctly.
However, when I expand the UserInfo row to show the related SessionInfo, at some point (around row 68 in SessionInfo) each subsequent sessioninfo is pushed on the top of the table, instead of being inserted into the bottom of the table.
So, when looking at just the SessionInfo table, the sessionPkey looks like this:
227 - 228 - 229 - 230 - ... 321 - 322 - 323 - 324
But when looking at the sessionPkey table as a subtable of the userInfo, it looks like this:
296 - 297 - 298 - 299 ... 321 - 322 - 323 - 324 - 227 - 228 - 229 - 230 ... 293 - 294 - 295
Does anyone know why this happens? I haven't changed the code used to insert into the table. Thanks.
~~~~~~~~~~~~
Over-worked, under-paid, glorified "secretary"
|
|
|
|
|
Hi ..
I want to use DataGridView as a data entry table << and I like to make alot of things like data verificatoin and don't move between rows before complete the existing fow...
I know that it isn't easy to do .. but if any one have any book or site which demonstrate the DataGridView as good .. I will be so happy ..
jooooo
|
|
|
|
|
Hi ..
I'm using SQL Server 2000 with VB6, vb.net ,,, and some times ( rarely ) on add new record , I found that the row is added to the table more than one time ..
and when I go to Edit or Delete this row , the next message is appear:
Key Column is Insufficient or Incorrect
Too many Rows were affected by update.
Notice:
There're no any constraitns or releations between that table and any other table
Really this problem is exhausting me
jooooo
|
|
|
|