|
Hi there,
I have a table with a column that I need to fill in with consecutive numbers (the field, currently, has the same number for all the rows).
I want to do this in the SQL Server Query Analyzer.
Could you please give me some hints about how can I do this?
Thanks a lot,
Cristina
|
|
|
|
|
Hi,
Try this ..........
<br />
DECLARE @Counter as int<br />
SET @Counter = 1<br />
<br />
DECLARE @ID as int<br />
<br />
DECLARE Table_Cursor CURSOR FOR<br />
SELECT TableID<br />
FROM TableName <br />
<br />
<br />
OPEN Table_Cursor<br />
<br />
FETCH NEXT FROM Table_Cursor INTO @ID<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
Update TableName<br />
SET<br />
SerialCol = @Counter<br />
WHERE TableID = @ID <br />
FETCH NEXT FROM Table_Cursor INTO @ID<br />
END<br />
<br />
CLOSE Table_Cursor<br />
DEALLOCATE Table_Cursor
I hope this will help u...............:->
Reagrds,
Ritesh
|
|
|
|
|
oops!!!! Forgot to increment @Counter i.e
FETCH NEXT FROM Table_Cursor INTO @ID
WHILE @@FETCH_STATUS = 0
BEGIN
Update TableName
SET
SerialCol = @Counter
WHERE TableID = @ID
SET @Counter = @Counter + 1
FETCH NEXT FROM Table_Cursor INTO @ID
END
Regards,
Ritesh
|
|
|
|
|
I want to execute a procedure in database2 from a procedure in database1. i want to pass a refcursor and get back the resultset. Is it possible to pass cursor variable in RPC? If not please let me know, how it can be done.
Thanks
|
|
|
|
|
how to create a custom data source in sql server 2000 reporting services
|
|
|
|
|
|
greetings
i did alot of work inb vb6 as frontent and sqlserver as backend, as with rapid change in technology, i've decided to swing to vb.net...and started some few job on it, but, i did find myself stuck in the area of using SQl, it seems it takes alot more than i thought in connecting database, viewing, editing, delete and update, unfortunately i cant find a good book that has samples and will realy give me the idea on how to make things easier.
hope u can direct me to anything that would be very usefull for me in understanding record connectivity in VB.net
thanks
cyrus
|
|
|
|
|
How do you make or set a DataSet to have LOCAL properties instead of GLOBAL?
Does it have to be in an exclusive Namespace?
For instance, if I create a new form, new adapter and dataset by design the wizard will give the default beginning name of the new dataset as dataset (which will be dataset1). All of my other forms with their dataset1 will have their properties changed to the last forms properties. All of them.
It is acting like the dataset name is global and adjusts all previous datasets with that particular name accordingly.
And if I create dataset11 or dataset111 or dataset112 it will see it as a subset(?) of dataset1 and all datasets that start with dataset1 or dataset1**** will be changed.
Nothing is changed inside of the SelectCommand just the DataSet.
Solutions?
Any comments would be grateful.
Rick
|
|
|
|
|
By hard coding it into your form.
If you create the DataSet by the wizard or using your toolbox, you create a globally named dataset for your project.
|
|
|
|
|
Hello all,
I'm populating a strongly typed dataset from a local XML file and I would like to establish a master-detail relationship between an element and a table of grandchild elements (and their attributes) which will be bound to a datagrid. Is it possible to do this without clicking through the child element on the datagrid? The XML file will be populated with multiple grandchild elements for each grandparent. Any help would be much appreciated (in C# if possible). Thanks.
-CS
|
|
|
|
|
This Stored Procedure YtdSales requires an input variable @title and the result of the query is returned in another variable @ytd_sales. Notice that the OUTPUT variable is clearly marked in the Stored Procedure. Also note the ParameterDirection attribute.
QES: How to run the Stored Procedure in Sql Query analizer,Pl give a
detail answer of how to get the output parameter value
Create Procedure YtdSales
@title varchar(50), @ytd_sales int OUTPUT
as
Select @ytd_sales=ytd_sales
from titles
where title=@title
return
|
|
|
|
|
DECLARE @MyTitle varchar(50),
@ytd int
SET @MyTitle = 'Some Title'
EXEC dbo.YtdSales @MyTitle, @ytd OUTPUT
SELECT @ytd
All you have to do is specify (again) that the parameter in the stored proc you are calling is an output parameter.
|
|
|
|
|
I am not sure if this is going to work but figure I mine as well try. I have a query that returns 2 columns and x rows. What I want to do is join simalar rows into the columns but not sure how I can get it done....
Example
Id Price
7812 25
7812 34
7813 67
7813 32
What I want to do is have the rows with the same Id show the 2 prices in the same row. Is this at all possible?
Thanks for all of your help!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
Only manually. Add prices as strings with separator ... use hashtable as intermediate
Hashtable ht=new Hashtable(1);
foreach(DataRow dr in myTable.Rows)
if(ht.Contains(dr["id"])
ht[dr["id"]]=ht[dr["id"]].ToString()+","+dr["price"].ToString();
else
ht.Add(dr["id"],dr["price"].ToString();
Next, clear DataTable and copy Hashtable into it. Not tested
Hi,
AW
|
|
|
|
|
I've been trying to cut my teeth on writing applications that read/write/query databases for some time now. In the past, I have used MS-Access to learn the basics of database theory and I have a pretty good handle on it: Tables, keys, normalization, joins, queries, etc - all using the SQL command window that Access provides. I don't have any problem with any of that.
However, when I attempt to use C# or MFC to get at my Access file, all hell breaks loose. My immediate problem is:
What must I do to gain access to my Access database file from an MFC or C# program? What drivers and connections must I set up - and how? I'm using Windows XP-Pro. I have found the ODBC Data Sources icon under the Administration Tools in Control Panel but I am absolutely stupified by the complexity of this and the bottom line is that I can't get it to work.
My problem in broader terms is that I can never find an explanation - for humans - that de-mystifies all of this database technology. It seems I have seveal database drivers installed on my system and I have no idea how they got there and I have no idea what to do with them. Invariably, when I consult somebody that understands databases, they start spouting all kinds of abbreviations, acronyms, jargon and terms that really make no sense to somebody who is starting out. I have done a thorough search of internet resources, books, etc... I find nothing helpful.
Some advice to solve my immediate problem would be appreciated. Some advise to solve my broader difficulties would earn a place in my will.
Thank you,
Jethro
|
|
|
|
|
Hi there,
I'm trying to modify data in SQL Server usin ADO
The followin code fails in windows 98
_CommandPtr pCommand;
pCommand.CreateInstance(__uuidof (Command))
Any idea why?
Thanks kumar
|
|
|
|
|
In Visual Studio.Net2003 on Report Layout
after execute my store procedure , we have data like this :
Sample Data Chart Of Account (COA) Code and Description.
'100000' -> Header | '100000' INCOME
'110000' -> sub Header | '110000' OTHER INCOME
'110001' ---> detail | '110001' Other Income Branch 15750
----> there is Sub Total | Sub Total Other Income 15750
'120000' -> sub Header | '120000' INTEREST
'120001' ---> detail | '120001' Interest from Bank 12500
'121001' ---> detail | '121001' Interest from Stock Market 07500
----> there is Sub Total | Sub Total Interest 20000
'200000' -> Header | '200000' EXPENSE
'210000' -> sub Header | '210000' Expense from Allowance 10550
'210001' ---> detail | '210001' Expense from Overtime 08450
----> there is Sub Total | Sub Total Expense 19000
-finally there is Grand Total | Grand Total (15750+20000-19000) 16750
(INCOME - EXPENSE)
in PowerBuilder if we want to compare data record we can use llike this :
if name1 <> name1 (-1) then..... --> this mean we compare current recorod with previous record
i tried this :
=iif(Fields!COA.code.value.sbstring(0,1) <> Fields!COA.code.value.sbstring(0,1)(-1), '...', '<else>'
but it doesn't correct
how do i compare between COA code 100000 with 1100000 in Visual Studio.Net 2003 with or without using Grouping Function ? (especially between first digit and the second digit)
and what is the correct syntax ?
email : sukasukabo@hotmail.com
|
|
|
|
|
I Prepared One Table with Selected Rows from another Table.
These Two tables have same schema. But Problem is i do Some
modifications in this Table. i want send this rows back to the original datatable.but that table already contains these
rows. so i have to update these rows. can anyone help me with a simple solution. Thanks in advance.
|
|
|
|
|
Hi,
u can merge two table using Dataset's Merge method as...........
Let ur original table is dtTable and ur filtered table is dtTemp.
dsNewData = New DataSet()
dsNewData.Tables.Add(pi_dtTable)
Dim dcCol(0) As DataColumn
dcCol(0) = pi_dtTable.Columns("emp_id")
pi_dtTable.PrimaryKey = dcCol
Dim dcCol1(0) As DataColumn
dcCol1(0) = dtTemp.Columns("emp_id")
dtTemp.PrimaryKey = dcCol1
dtTemp.TableName = pi_dtTable.TableName
dsNewData.Merge(dtTemp, False, MissingSchemaAction.Ignore)
I hope this will help u..............:->
Regards,
Ritesh
|
|
|
|
|
hye
i'm tring to read meta tag that contains name="KeyWords" content="something"
the query is : select DocKeyWords from scope()
the result = " " ....
------------------------------------------
i have in the same html file title tag , and when i read DocTitle -> the result are correct !
------------------------------------------
so why i can't read the meta tag ???
tnx a.r
|
|
|
|
|
Hi,
I want to create a custom rendering extension based on a existing rendering,
I have seen in the MSDN that it is possible but the documentation is not
complete
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_prog_extend_security_87oi.asp
If somebody know how i can do ...
Thanks in advance...
|
|
|
|
|
Have you generated report in HTML format, If so before writing Binary converted data to Response, make the Content type as
"application/PDF" for PDF or "application/vnd.ms-excel" for EXCEL
Don't forget to pass the report format as desired type(PDF or EXCEL ) when you are Rendering the report to binary format.
For EXCEL to work Excel 10 or above is required.
Hope this helps.
Regards
JK
|
|
|
|
|
Should i use SqlConnection to connect to server before i use SqlDataAdapter to to fill the dataset ?
Example :
=============
<br />
string ConStr = "server=(local);uid=sa;pwd=password;database=NorthWind";<br />
string cmdString = "select top 3 last name, firstname, title from employees";<br />
SqlConnection conn = new SqlConnection(ConStr);<br />
SqlCommand com = new SqlCommand(cmdString,con);<br />
SqlDataAdapter da = new SqlDataAdapter(com);<br />
DataSet ds = new DataSet();<br />
<br />
conn.open();
<br />
da.Fill(ds);<br />
I try code above and i found that even without manuall open the connection i still able to fill up the dataadapter (da).
So what is the best method to fill the dataadapter with out connection first out without using connection?
|
|
|
|
|
If your connection is closed already - the DataAdapter will open the connection, perform the query, and close the connection again. If you do not need the connection open for anything else then I recommend you let the DataAdapter do the clean up for you.
[ADDITIONAL] I should add that if the connection is already open the DataAdapter will not close it [/ADDITIONAL]
If you are going to perform a series of queries one-after-the-other then I would recommend that you open the connection, perform your queries, then close the connection.
Does this help?
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Thanks it really help and clear all my doubt.
|
|
|
|