|
Dave2909 wrote: create function callme()
returns TABLE AS
RETURN(exec MyExistingSP)
You can't do this -
1. You can't call a proc from a function
2. You can't pipe the output from a proc into a table
Regarding only getting the first few rows, try
SET ROWCOUNT 10
exec sproc
SET ROWCOUNT 0
This will just return the 1st 10 rows.
As for the rest of it, the only way to do it would be some pretty complex dynamic sql.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Thanks, Bob...just wish there was a different answer.
The more I think about this though, it just seems that there really should be some way to do a sub-query against a stored proc's result set from SQL Server management studio without having to define specific tables, or do anything funky like parsing the SP to auto-create a result table. Perhaps I just need to add this into a feature request for MS.
Just in case...anyone else have a suggestion on how to narrow down the results of a stored proc from within Management studio? Something like being able to run a query against the results window sure would be handy.
Thanks,
Dave
|
|
|
|
|
I got the SQL Azure Service up and running. It is running of the hosted server
MyCloud Service
While working on this app, I found some interesting things. Here is a short summary
1. select * from sys.objects IS YOUR NEW OBJECT BROWSER
2. truncate table tablename will not work in SQL Azure - yes,drop and delete does work.
3. select @@servername will not work but select @@version does work
4. DO NOT TRY exec sp_help and exec sp_who – it will not work
5.Insert WILL NOT WORK if you forget to add a primary key on your table - For example
create table test
(
my_id int,
my_name varchar(10)
)
insert into test values (1,'abhi')
and you will get an error –“ Heaps can not be replicated tables. Please create a clustered index for the table.” . Just add a PK on my_id and things will work as expected
6. Migrating data from your local DB to the cloud is not easy - check out http://www.stephenforte.net
7. Copy connection string from your https://sql.azure.com/ServerInfo.aspx page - this is the easiest and fastest way to connect your app with SQL Azure
abhi
Zimbatech Solutions
|
|
|
|
|
How we can handle mails using trigger if exchange server is down. i Am sending mail on insert of any record in table through trigger. But if exchange server is down how we can handle mails.
|
|
|
|
|
We solved this problem, by sending emails through an application.
The application will try to send the email as usual, but in case the exchange server is down, or the email can not be sent for some other reason, all relevant data (addresses, message body, etc.) is stored into a database table instead.
Another application then checks the table periodically, and will attempt to send any message there. If sending is successful the app will flag the message as sent.
My advice is free, and you may get what you paid for.
|
|
|
|
|
thanks bro but i dont want use another application to send mails. I want to send mails through triggers.
I know we can use web service to send mail. But i m tring to send mails through triggers.
|
|
|
|
|
The core problem is, what happens when your trigger is unable to send a message, right?
The question is what do you want to happen? Should your solution use an alternative medium (for example POP)? But what if the connection between the database server and the rest of the network is broken? Then you won't be able to access any alternative at all.
From your original message I understand that you are already sending emails through triggers.
Why not use our approach, but adapted to work with triggers?
Trigger --> if sending message fails --> message to table
SQL job --> check table every minute or so --> send message using same code you are using in your triggers
Message sent successful --> flag message in table as sent or delete from table.
My advice is free, and you may get what you paid for.
|
|
|
|
|
thanks for ur response i m agree with ur answer. i think taking flag is better option.
|
|
|
|
|
Your welcome, however please vote "5" or "good answer" next time. You have marked my answer as bad.
My advice is free, and you may get what you paid for.
|
|
|
|
|
ohh sorry i dont know...i don't do it intensionally
|
|
|
|
|
Hi
I'm using the in query like
select * from table where col in ('1,2,3,4')
that is a simple query but i'm here in norway where they use (,) as a decimal point and (.) as comma. They when I use the query like this
select * from table where col in ('1.2')
it works fine but when I use query like this
select * from table where col in ('1.2.3.4.5')
It gives an error that error converting datatype......
What is the solution of tis hell.
Thanks
Syed Shahid Hussain
|
|
|
|
|
The solution is to use the decimal separator as a decimal separator, and not as a separator for arguments.
select * from table where col in ('1,2,3,4')
Now, if you want to use four decimals in that place, you'd use the English notation;
select * from table where col in ('1.2,2.9,3.83,4.0')
It's a good idea to keep the database culture-agnostic, and to format the decimal just before displaying. That means that each number is treated internally like we're in England, and that everything that gets displayed is formatted from that generic English form into the current culture.
I are Troll
|
|
|
|
|
Thanks Eddy
But my problem is some thing different
the col field is nvarchar and now i want to use it in IN query. There is no floating point here. then what will be the query it all values in the column are in integers. How can i put them in IN query.
Any idea about that.
Thanks
Syed Shahid Hussain
|
|
|
|
|
Syed Shahid Hussain wrote: How can i put them in IN query.
My apologies, there was another error that I missed. The arguments after the IN operator are summed within a varchar (a string), and SQL expects a list of items, not a string. It tries to convert the entire string to the datatype of "col".
This code should run fine, even when the locale is Norsk;
SET LANGUAGE 'Norwegian'
DECLARE @myTable AS TABLE ( id INT)
INSERT INTO @myTable VALUES(1)
INSERT INTO @myTable VALUES(2)
INSERT INTO @myTable VALUES(3)
INSERT INTO @myTable VALUES(4)
SELECT * FROM @myTable WHERE id IN (1,3) As you can see, the arguments in the select -list are separated by comma's (allowed, since they're not decimals) and there are no quotes (indicating multiple values to check against, as opposed to a single varchar value)
That would translate to your query like this;
select * from table where col in (1, 2, 3, 4)
Or for decimals;
select * from table where col in (1.2, 3.89)
Make sure that the datatype of col matches the datatype of the values that you put after the IN operator
I are Troll
|
|
|
|
|
Thanks a lot
its for you
Syed Shahid Hussain
|
|
|
|
|
Thanks
|
|
|
|
|
Bah...at first glance I thought this was unanswered....in any case, drop the '' inside your IN and give it a list of separate values - sounds like that's already fixed ya right up...
-Dave
|
|
|
|
|
Hi All,
I have developed an application using C# WinApp VS 2005 and MYSQL 5.0.1. My Query is it
possible by any means that I can create a setup application that can identify and install MySQL
Server on the deployment machine if its not installed on it. Also it will run the script file to create
database and user into MySQL Server. I have done some googleing but was unable to find
appropriate answer. Can it be done using InstallShield? If so, How to do it?
Its very urgent.
Please Help me.
Thanx in Advance,
Regards,
Paramhans Dubey
|
|
|
|
|
Hi Paramhans,
I'm also facing the same problem.
If you get the solution pleaseeeeeeee let me know.
agarwal.vineeta@yahoo.com
Thanks
Vineeta
|
|
|
|
|
When you are deploying any project then you can specify the prerequisites for that project. Here Mysql 5.1 is the prerequisite of your application. VS provides some default prerequisites. If you don't find the required one there then you can create custom prerequisite and include it there.
|
|
|
|
|
HI Nisha,
Thanx for your reply. Can you please tell me how to create custom Prerequisite and How to include it with the setup.
Please guide me.
Thanks again.
|
|
|
|
|
|
Thanks Nisha my problem is solved now.
|
|
|
|
|
I am facing the same problem plz send me the solution on my mail address
abdullah555@yahoo.com
|
|
|
|
|
Hi,
I am having two table which are related with primary and foreign key constraints. I want to delete records from both the tables using innerjoin.
I applied like this,
delete sports,studentregtable
from studentregtable as sr
INNER JOIN sports sp ON sr.registerNo = sp.RegisterNumber
where RegisterNumber = '123'
but it is giving an error like incorrect syntax near ",".
can you please help me if you know the solution.
|
|
|
|