|
SQL Server Books Online:
Using Cursors[^]
Declare Cursor (T-SQL)[^]
Example:
CREATE PROCEDURE MyProcedure @cMyParameter varchar(100)
AS
DECLARE @cMyVar varchar(100)
DECLARE mycursor CURSOR FOR
SELECT MyField
FROM MyTable
WHERE MyOtherField = @cMyParameter
OPEN mycursor
FETCH NEXT FROM mycursor INTO @cMyVar
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM mycursor INTO @cMyVar
--do some processing
END
CLOSE mycursor
DEALLOCATE mycursor
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I want to use report services in SQL server 2005 express edition. Does it require IIS?
Thanks
|
|
|
|
|
I'm not sure about the Express Edition, but Reporting Services, in general, requires IIS, at least 5.0, and ASP.NET 2.0.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Does anybody know what we need to read out an Access database?
Is MS Access really needed or can you install a provider only (or Access only without the rest of Office)? We need to show the data in our application only. (the users don't have to open the file itself) Currently the client provided the data in a mdb file, which occasionaly can be updated. Unfortunately this application has to be installed on several hundreds of workstations where Office is not installed.
The application is a html application embedded in our product. I use javascript to access the db.
Thanks a lot for your help...
|
|
|
|
|
V. wrote: has
The MS access oledb provide (ADO0) is intalled with the system in in "program files\common files\system\ADO"
The Jet engine dllas are normally around in windows\system32
As a result, you should not have to intall anything if you are using ADO/ADO.Net to read from the file.
If these are old clients (win2k, ME, Win98 etc.) you may need to install ADO and possibly the jet engine stuff.
Redistributables can be found here[^]
|
|
|
|
|
Hey man,
thanks a lot, this is really helpfull !
|
|
|
|
|
i am having a database and i entered some data and deleted it also.Now the Primary Key starts from 4 or say any thing..i want it to start it from 1.And the primary key is auto incremented and not for replication.So how to do it.Please help me out.
Mohinder Singh
|
|
|
|
|
DBCC CHECKIDENT[^]
DBCC CHECKIDENT('MyTable', RESEED, 0)
You need to be logged on as a user with at least one of the following roles: sysadmin , db_owner or db_dlladmin
|
|
|
|
|
Rename ur column[PK].
Add new column with the name of pk column.
Now delete the column u renamed.
Your problem will be solved.
Do good and have good.
|
|
|
|
|
That is the craziest solution I've heard!
|
|
|
|
|
Best Regards,
Apurva Kaushal
|
|
|
|
|
|
No, it won't! You'll just create an empty column. The key ID's won't be regenerated for any existing rows.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi
How can i extract hour from datatime varable???
Good bye
Best Regards
N.Nikolov
when i want to read something good just seat and type it
|
|
|
|
|
This is what i know you can use this code to extract hour from datetime variable
COleDateTime oOleDateTime(DateTimeVariable);
int iDay = oOleDateTime.GetDay();
int iMonth = oOleDateTime.GetMonth();
int iYear = oOleDateTime.GetYear();
int iHour = oOleDateTime.GetHour();
int iMinute = oOleDateTime.GetMinute();
int iSeconds = oOleDateTime.GetSecond();
|
|
|
|
|
Thank's a lot
when i want to read something good just seat and type it
|
|
|
|
|
Hi
Can i get parameters from the user at run time in a SQL Procedure. I want to implement a SQL function just like i used to do in my C++ introductory classes. In the function, i want to ask user to enter name, age, class, and address etc one by one and then i would store this record using INSERT query. Can anyone plz help me?
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
SQL Server is a database server, and has no "run time" user interface development tools. You need to write your interface in a programming language (C++,C#,ASP,etc.), then connect to SQL Server via some data connection method (ODBC,OLEDB,etc) and send your "INSERT query" to SQL Server.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
It might be crazy, but i really wanna know if a hashtable (or any array of user defined type) can be save to database as a single object...and how?
any ideas? thanks~
|
|
|
|
|
hi
yes
u can do by converting your hashtable to DataTable or DataSet
fsdfsdfd
|
|
|
|
|
Serialize to a byte array, then store in a varbinary field. When you read it back from the database, deserialize back into a hash table. This obviously only works with serializable objects. Also, if the implementation (of hashtable) is changed at some time, reading back a hashtable from the old serialized format will fail. Also, a varbinary can only hold 8000 bytes, and you need to use an image field if you will have more than 8000 bytes.
Scott
|
|
|
|
|
Hi,
I have tables:
Fruits:
FruitID | FruitName
====================
1 | Apple
2 | Orange
3 | Pear
Baskets:
Basket | FruitID | Amount
========================
Bask1 | 1 | 3
Bask2 | 1 | 5
Bask3 | 1 | 2
Bask1 | 1 | 1
Bask2 | 1 | 2
Bask1 | 3 | 2
Bask3 | 3 | 4
What query can I use to get the following table:
Basket | Apple | Orange| Pear
=============================
Bask1 | 3 | 1 | 2
Bask2 | 5 | 2 | NULL
Bask3 | 2 | NULL | 4
Thanks in advance,
-----------------
Genaro
|
|
|
|
|
select fruits.*,baskets.*<br />
from fruits,baskets<br />
where fruits.FruitID = Baskets.FruitID
|
|
|
|
|
SELECT b.Basket AS Basket, b.Amount AS APPLE
FROM Fruits INNER JOIN
Baskets b ON Fruits.FruitID = b.FruitID
WHERE (Fruits.FruitID = 1)
SELECT c.Basket AS Basket, c.Amount AS ORANGE
FROM Fruits INNER JOIN
Baskets c ON Fruits.FruitID = c.FruitID
WHERE (Fruits.FruitID = 2)
SELECT d.Basket AS Basket, d.Amount AS PEAR
FROM Fruits INNER JOIN
Baskets d ON Fruits.FruitID = d.FruitID
WHERE (Fruits.FruitID = 3)
This will not give u the exact solution but will give you the partial solution.
Do good and have good.
|
|
|
|
|
This is the standard way of doing a Crosstab/PIVOT in SQL.
SELECT Basket,
SUM(CASE FruitID WHEN 1 THEN Amount ELSE 0 END) AS Apple,
SUM(CASE FruitID WHEN 2 THEN Amount ELSE 0 END) AS Orange,
SUM(CASE FruitID WHEN 3 THEN Amount ELSE 0 END) AS Pear
FROM Baskets
GROUP BY Basket
However, as you can see, you need to know in advance what the columns are. There is a new PIVOT command in SQL Server 2005 that may extend this functionality.
The other way is to de-normalise the data using
SELECT b.basket, f.FruitName, b.Amount
FROM Baskets b INNER JOIN Fruit f on b.FruitID = f.FruitID
and import it into Excel where you can use the Pivot tool to do the crosstabbing for you.
Ian
|
|
|
|