|
Sonia - will you please buy some books? And will you start off by learning to use google? This information is readily available with a simple search.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
@ parameter are defined by user they are local variables in Sql. but @@ variables are global and defined by system only....
|
|
|
|
|
CREATE FUNCTION [dbo].[waste] ()
RETURNS table
AS
declare @a int
declare @b int
BEGIN
declare cur cursor for select a1,a2 from a
open cur
fetch next from a into @a,@b
while @@FETCH_STATUS =0
BEGIN
SELECT @a as a1 , @b as a2
fetch next from a into @a , @b
END
close cur
deallocate cur
return
END
where is the bug lying?
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
1. remove BEGINafter the Decleration of A & B
2. and include before before A & B
Regards
KP
|
|
|
|
|
CREATE FUNCTION [dbo].[waste] ()
RETURNS table
AS
declare @a int
declare @b int
declare cur cursor for select a1,a2 from a
open cur
fetch next from a into @a,@b
while @@FETCH_STATUS =0
BEGIN
SELECT @a as a1 , @b as a2
fetch next from a into @a , @b
END
close cur
deallocate cur
return
GO
Now it is saying
incorect syntax near the keyword declare.
return statement statement i scalar valued function must include an argument
Soniagupta1@yahoo.co.in
Yahoo Messenger Id = soniagupta1
|
|
|
|
|
youre declaring that the fn will return a table and look at the last line
Sonia Gupta wrote: return
GO
whats happening here??
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
You have not specified that which type of function you want to create means scalar valued function or table valued function.
I suppose that you want to create table valued function. For that your code is wrong in the starting line.
Look at the below code. Hope it will guide you.
CREATE FUNCTION [dbo].[waste]()
RETURNS @student1 TABLE
(
student_rec int,
St_name nchar(10)
)
AS
Begin
declare @a int
declare @b nchar(10)
declare cur cursor for select Id,name from student
open cur
fetch next from cur into @a,@b
while @@FETCH_STATUS =0
BEGIN
INSERT @student1 values(@a,@b)
--SELECT @a as a1 , @b as a2
fetch next from cur into @a , @b
END
close cur
deallocate cur
RETURN
end
Neeraj Gupta
IndiaNIC Infotech Ltd.
|
|
|
|
|
hi all,
i m ganesh new to code project....
i jus want to know all information about CORBA and MSP for database connection. Is anyone to help me out? n the details needed asap...thnks in advance...
GANESH
|
|
|
|
|
hellogany wrote: i jus want to know all information about CORBA and MSP for database connection
I think if we were to tell you ALL the information about that then we'd exceed the forum guidelines for length of post. Have you tried google?
|
|
|
|
|
hellogany wrote: want to know all information about CORBA
It is a very big topic and not one that can have all parts covered in a post. You are best to start researching...
"Find it your bloody self - immediately!" - Dave Kreskowiak
|
|
|
|
|
hi all
i have a table called Employee and Employees. i want to see if these tables have a same value on the following Fields "EmployeeName","Lastname", all this tables have the a Primary key called "Primary_KEY", how can i check if there is any record that is not the same and Display it. thanks
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
For SQL-Server:
select E1.Primary_Key, E2.Primary_Key,
IsNull(E1.EmployeeName, E2.EmployeeName) AS EmployeeName,
IsNull(E1.LastName, E2.LastName) AS LastName
from Employee E1
full outer join Employees E2
on E1.EmployeeName = E2.EmployeeName
and E1.LastName = E2.LastName
where (E1.Primary_Key is null or E2.Primary_Key is null) Regards
Andy
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".
|
|
|
|
|
Thanks and Rate for your Reply
I will try it
Rated
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hello Everybody !!
How Can I put a default value in dataColumn
Thanks
Sarfarj Ahmed
|
|
|
|
|
Hi all,
I have this problem:
i want to write a select statement. But i am connected to one server and i want to select on another database on another server????
How do i go about doing so?
if i run this script:
SELECT
a.*
FROM
OPENROWSET('SQLOLEDB.1','Data Source=<OurServerName>;Initial Catalog=<OurDataBaseOnThatServer>;User ID=<OurUserName>;password=<OurPassword>;','SELECT TOP 1 FROM <OurServerName>.<OurDataBaseOnThatServer>.dbo.<TableNameInThatDataBase>') a
Am i doing something wrong??? i get an error: "Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'SQLOLEDB.1' reported an error."
Please advise
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
I found this code on the internet BUT i haven't run it yet.
EXEC sys.sp_configure N'show advanced options', N'1' RECONFIGURE WITH OVERRIDE<br />
go<br />
<br />
EXEC sys.sp_configure N'Ad Hoc Distributed Queries', N'1'<br />
go <br />
<br />
RECONFIGURE WITH OVERRIDE<br />
go<br />
<br />
EXEC sys.sp_configure N'show advanced options', N'0' RECONFIGURE WITH OVERRIDE<br />
go
Do you think this could solve my problem?
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Probably.... Its better practice to add the other server as linked server if you are going to use the connection often enough. It will simplify your query writing (no openrowset crap needed).
Redneckin with www.wantedband.com
|
|
|
|
|
I have seen that to use OPENROWSET command the first parameter should be MSDASQL
the SQLOLEDB is used for OPENDATASOURCE. i have tried this query and working perfectly. Also i hope that you have already enabled the OPENROWSET and OPENDATASOURCE command from the SQL server surface area configuration wizard.
SELECT *
FROM OPENROWSET('MSDASQL',
'DRIVER={SQL Server};SERVER=yourremoteserver_name;UID=your_remote_user_id;PWD=your_remote_password',
your_remote_database_name.dbo.remote_table_name)
Neeraj Gupta
|
|
|
|
|
Hi,
I want only count of a records returning by a particular stored procedure..
Im trying like this..but not coming..
DECLARE @COUNT INT
SET @COUNT = EXEC 'SP NAME'
SELECT @COUNT
please help me..
bala
|
|
|
|
|
SELECT COUNT(*) FROM TABLE WHERE Variable = @Variable.
Hope it helps.
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
hi,
thanx for ur reply..
but i want count of (number only) records returing by a particular stored procedure..not table records count..
bye
|
|
|
|
|
@@ROWCOUNT will return the no. of rows affected by the last operation in the current session.
Paul Marfleet
|
|
|
|
|
hi paul, thanx for ur reply..
but in this scenario rowcount will not work.. im trying like this
DECLARE @COUNT INT
SET @COUNT = EXEC 'SP NAME'
SELECT @COUNT
can we capture only count of records returning by stored procedures like this??
|
|
|
|
|
Works OK when I try it...
Paul Marfleet
|
|
|
|
|
You can use @@ROWCOUNT in your stored procedure and take the value returned by @@ROWCOUNT as output parameter of stored procedure.
|
|
|
|