|
|
Hello!
I need to write a stored procedure that will make a query, and then return a value depending
on the query result.
My question is how can I store the query results inside the stored procedure for me to be able
to examine them and then return an appropriate result?
Thanks in advance!
Have a nice day!
|
|
|
|
|
You want to store your query and then query that in a stored procedure? Can you not just do a bigger better query?
You can use cursors to do iterative stuff if need be but its best avoided.
Regards,
Rob Philpott.
|
|
|
|
|
Declare a temp table and save the result set inside that table. Make sure to drop it before you exit the stored procedure.
|
|
|
|
|
Can you give me a simple example? I would be very thankful...
Have a nice day!
|
|
|
|
|
Found an example by googling. Thanks!
Have a nice day!
|
|
|
|
|
Hi,
I'm Using Asp.Net with C# & Sql Server 2005..
I'm Generating Reports in SSRS 2005..
I want to Generate the Reports DYNAMICALLY in Local Mode at web-based applications..
Here I'm having One Stored Procedure which Returns UserID's.. I want to Display all the ID's in One DROPDOWNLIST Control.. By Selecting the ID's from Dropdownlist control, I want to Generate the Reports(Dynamically)..
How to Do this..
Please give me the Suggestions...
Thank You
|
|
|
|
|
in my source table i have '1530' as char data type which is actually a time (HHMM)
in my destination table the column is datetime. how could i convert '1530' and insert into destination table of type datetime.
please help
|
|
|
|
|
Hey there!
It is a bit hard to convert it to dateTime from just 24hrs Time format. From the little knowledge you have, you could play around with the following syntax but I am sure that it won't return you the proper result.
Syntax: convert(varchar(24),cast(1530 as datetime),8)
It would be wise to just do it on the front end if you are using it. In C#, you can achieve this by:
DateTime _dteDateTime = Convert.ToDateTime("1530").ToString("hh:mm");
If you are using VB.Net, I think the syntax was:
FORMAT(Node, "yyyy-mm-dd")
Hope that this helps.
------------------------------------------------------------------------
If there was no SQL, there would be no sequels to programming.
|
|
|
|
|
Hi,
MAX() function returns the max value from a specific column of the table, but i want to get the max value from a row.
Assume the following table.
col1 col2 col3 col4 col5 col6
0 7 9 3 4
5 6 10 8 1
I want to update the col6 whith the max value in that row. For the above example col6 will have 9 in first row and 10 in second.
I don't know the exact number of columns in the table. There can be any number of columns and i have to find the max from all columns.
Can anybody help me in this regard.
Thanks in advance.
Regards,
Sulaman Riaz
|
|
|
|
|
I think its kind of a given in SQL that you know how many columns you're dealing with and the name of each one. If you're a blindingly clever lunatic you maybe be able to query the metadata of the table and produce some uber proc to do this.
Personally, I'd have a go with a bit of code.
Regards,
Rob Philpott.
|
|
|
|
|
Can anyone recomend me a good SQL Script generator (A free one)?
Ive tryed:
SQL 2000 Sript generator and SQL Express Generator (Both of them create scripts in the wrong worder, and when executing the script, it fails) I CANT BELEIVE IT
Ive also tried Database publishing wizard (This one doesnt works because of functions that return table results i havent tryed removing those functions but i guess that it will create scripts in the wrong order)
Thanks for any suggestions
Alexei Rodriguez
Alexei Rodriguez
|
|
|
|
|
|
Hi All,
I have 2 reports, one a main report and the other a subreport.
My question is, Will i be able to change or refer to a control(item) in the main report depending on the value of an item in the subreport, when the subreport is being run? If yes how?
Any comments are appreciated.
Thanks in advance.
Payal
|
|
|
|
|
Hello....
I am trying to understand this parameter "Connection LifeTime" in the connection string.
The definition says "Connection Lifetime - When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime.
A value of zero (0) causes pooled connections to have the maximum connection timeout. "
Connection Lifetime - if I set the value for this to be 5 secs, does it mean that after I close my connection, and gets returned to the pool, and if the difference of the creation time and the returned time is greater than 5 secs, will the connection be available for use immediately, from the connection pool? Or do I loose this connection from the pool?
Or am I reading it incorrectly? What is the maximum connection timeout?
Please advice...
Thank You
|
|
|
|
|
Simply, connection timeouts refer to the time it takes the Server to run a query and generate a result. If you reach connection timeout, your conenction to the database will be terminated and you will need to re-initialise the connection to the database.
When we talk about Pooling, what that refers to is that when you try and make a connection to the database, the server tries to make contact with the database engine. If you set the timeout value to 5, it will try for 5 seconds and if no connection has been established, it will return you an error (Connection Timeout). Which means that you didnt have a connection to begin with. If you do establish a connection and then leave the connection (Close()), you will again lose the connection and you will need to go through the same process of establishing the connection.
Hope that this helps.
Regards,
Ali
|
|
|
|
|
Hello
This is the statement, which I am use in Sql Base
select IF (@SCAN (@UPPER(enota),'MI') ,1 , 60 ) , 2
from
members;
How can I execute similiar statement in SQL Server?
Thanks
lp
|
|
|
|
|
|
Hello!
I am writing a stored procedure that should insert a row in a table that it's name is sent to it as a parameter.
I do it this way:
CREATE PROCEDURE myProcedure
@tablename ntext,
AS
INSERT INTO @tablename(...)
and I get an error "Must declare the table variable "@tablename"".
What should I do?
Thanks in advance!
Have a nice day!
|
|
|
|
|
Solved the problem. I'm using EXEC instead of an explicit INSERT.
Have a nice day!
|
|
|
|
|
Which one is feasible to store data?
Sutheesh Ramachandran
Cybernet Software Systems,
T Nagar, Chennai 17.
|
|
|
|
|
That's something of a broad question there. XML doesn't store anything - it's a mark up language. You store your data as XML, and you could do this in a file or a database or something.
SQL is a query language for querying relational databases. Typically databases are geared to storing things in a tabular fashion.
If the data you want to store is hierarchial in nature then XML is a good choice, if tabular then a database table is a good choice.
Sql Server 2005 has quite good support for XML and you can use XQuery within stored procs to query stuff stored as XML.
Regards,
Rob Philpott.
|
|
|
|
|
hi there,
i have a column contain some values..i just want to copy the data of column to same column after orginal data.
means if the column contains 1,2,3 and i copy the same column in it then it will be 1,2,3,1,2,3
Hope u understand
what can do ???
Regards and thankx in advnace
Koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
What datatype is the column?
Regards,
Rob Philpott.
|
|
|
|
|
koolprasad2003 wrote: means if the column contains 1,2,3 and i copy the same column in it then it will be 1,2,3,1,2,3
I assume from this the column is a varchar or char, so
update table1<br />
set col1 = col1 + ',' + col1
will do the job. Watch out for nulls though.
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|