-
Syntax Headache!!!
I need to get this statement to run.
Declare @MiD datetime
-- The ATime is a datetime field in the table
-- @OrderBy is an input Parameter also, as is @MiD
SELECT @Statement = 'SELECT tblAudit.* FROM tblAudit WHERE ATime >= ' + @MiD + ' ORDER BY ' + @OrderBy
EXECUTE(@Statement)
@Statement then contains:
SELECT tblAudit.* FROM tblAudit WHERE ATime >= Mar 10 1999 ORDER BY Access_ID
I need the quotes around the Mar 10 1999.
Thanks for the help
-
Syntax Headache!!! (reply)
Hi Patrick.
I usually do it like this:
SELECT @Statement = 'SELECT tblAudit.* FROM tblAudit WHERE ATime >= ' +
char(39) + @MiD + char(39) + ' ORDER BY ' + @OrderBy
EXECUTE(@Statement)
will give you:
SELECT tblAudit.* FROM tblAudit WHERE ATime >= 'Mar 10 1999' ORDER BY Access_ID
/Kenneth
------------
Patrick Baird at 3/13/99 8:05:13 AM
I need to get this statement to run.
Declare @MiD datetime
-- The ATime is a datetime field in the table
-- @OrderBy is an input Parameter also, as is @MiD
SELECT @Statement = 'SELECT tblAudit.* FROM tblAudit WHERE ATime >= ' + @MiD + ' ORDER BY ' + @OrderBy
EXECUTE(@Statement)
@Statement then contains:
SELECT tblAudit.* FROM tblAudit WHERE ATime >= Mar 10 1999 ORDER BY Access_ID
I need the quotes around the Mar 10 1999.
Thanks for the help
-
Syntax Headache!!! (reply)
Thanks!!!!
------------
Kenneth Wilhelmsson at 3/13/99 11:52:00 AM
Hi Patrick.
I usually do it like this:
SELECT @Statement = 'SELECT tblAudit.* FROM tblAudit WHERE ATime >= ' +
char(39) + @MiD + char(39) + ' ORDER BY ' + @OrderBy
EXECUTE(@Statement)
will give you:
SELECT tblAudit.* FROM tblAudit WHERE ATime >= 'Mar 10 1999' ORDER BY Access_ID
/Kenneth
------------
Patrick Baird at 3/13/99 8:05:13 AM
I need to get this statement to run.
Declare @MiD datetime
-- The ATime is a datetime field in the table
-- @OrderBy is an input Parameter also, as is @MiD
SELECT @Statement = 'SELECT tblAudit.* FROM tblAudit WHERE ATime >= ' + @MiD + ' ORDER BY ' + @OrderBy
EXECUTE(@Statement)
@Statement then contains:
SELECT tblAudit.* FROM tblAudit WHERE ATime >= Mar 10 1999 ORDER BY Access_ID
I need the quotes around the Mar 10 1999.
Thanks for the help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|