Hello everybody!
I have a question for you.
In access, you can make a query using parameters:
DELETE *
FROM tableName
WHERE myDate < [DATE]
[DATE] is a question asked to the user.
Can we do the same in SQL Store procedures?
I've tried the ? and %DATE% but it don't work.
Tanks all!
MarianneSQL Server runs on the server machine, so it cannot be made to pop up any
type of dialog on the client machine. I.e., you cannot have any type of user
interaction inside a stored procedure. Do this in the client application
instead and pass the value as a parameter to the stored procedure.
--
Tibor Karaszi
"Marianne Novello" <anonymous@.discussions.microsoft.com> wrote in message
news:077601c3a3aa$4dadf600$a001280a@.phx.gbl...
> Hello everybody!
> I have a question for you.
> In access, you can make a query using parameters:
> DELETE *
> FROM tableName
> WHERE myDate < [DATE]
> [DATE] is a question asked to the user.
> Can we do the same in SQL Store procedures?
> I've tried the ? and %DATE% but it don't work.
> Tanks all!
> Marianne
>|||Try:
CREATE PROCEDURE myproc
int @.myvariable
AS
SELECT @.myvariable
DELETE FROM mytable WHERE mytable.myfield = @.myvariable
GO
Take a look "CREATE PROCEDURE" in BOL.
Regards
---
All information provided above AS IS.
"Marianne Novello" <anonymous@.discussions.microsoft.com> wrote in message
news:077601c3a3aa$4dadf600$a001280a@.phx.gbl...
> Hello everybody!
> I have a question for you.
> In access, you can make a query using parameters:
> DELETE *
> FROM tableName
> WHERE myDate < [DATE]
> [DATE] is a question asked to the user.
> Can we do the same in SQL Store procedures?
> I've tried the ? and %DATE% but it don't work.
> Tanks all!
> Marianne
>|||Hello,
In SQL server you cant provide a parameter during run time. Instead you have
to execute the statement along with parameter value.
Sample:
declare @.date datetime
set @.date= getdate()
DELETE FROM tableName WHERE myDate < @.date
You can stored procedures also to do the similar stuff.
Thanks
Hari
US Technology
"SkyWalker" <tcp_43@.hotmail.com_TAKETHISOFF> wrote in message
news:erTWbu6oDHA.2964@.tk2msftngp13.phx.gbl...
> Try:
> CREATE PROCEDURE myproc
> int @.myvariable
> AS
> SELECT @.myvariable
> DELETE FROM mytable WHERE mytable.myfield = @.myvariable
> GO
> Take a look "CREATE PROCEDURE" in BOL.
> Regards
> ---
> All information provided above AS IS.
> "Marianne Novello" <anonymous@.discussions.microsoft.com> wrote in message
> news:077601c3a3aa$4dadf600$a001280a@.phx.gbl...
> > Hello everybody!
> > I have a question for you.
> >
> > In access, you can make a query using parameters:
> >
> > DELETE *
> > FROM tableName
> > WHERE myDate < [DATE]
> >
> > [DATE] is a question asked to the user.
> > Can we do the same in SQL Store procedures?
> > I've tried the ? and %DATE% but it don't work.
> >
> > Tanks all!
> > Marianne
> >
>
No comments:
Post a Comment