473,462 Members | 1,243 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MS SQL - User Selected Parameters

1
We are modifying a report that allow users to select just one value from 1 to 13 (numeric). (No multiple selections allowed.)

I would like to name this parameter as @n

The value is based on this similar query.

Select DateAdd(Month, 3, @StartDate)


The original declaration is:

DECLARE @StartDate AS DateTime
Set @StartDate = DateAdd(Month, DateDiff(Month, 0, GetDate()) - 1, 0)


-------------------------------------------------

The ideal query is like this:

Select DateAdd(Month, @n, @StartDate)

User will be prompted to select a parameter value from 1 to 13. If I select 5, it will be equivalent to:

Select DateAdd(Month, 5, @StartDate)


Then, this query will be executed based on the value selected.

I declare @n as numeric. If it was incorrect, please let me know. Thanks.

---------------------------------------

When I first declared and executed, it failed on scalar value.

Declare @n as numeric
--Set @n ???? --- Please advise.
Nov 3 '10 #1
1 2311
ck9663
2,878 Expert 2GB
When you say "user will be prompted" are you talking about some sort of form or GUI? If you are and the StartDate value is available on that time, calculate it on the front-end and not the back-end.

Good Luck!!!

~~ CK
Nov 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Nathaniel Maier | last post by:
Hi. How can I send form results to an email address based on what the user selects? e.g. not to the same address all the time, and not to all addresses, but to the one that the user selects. How...
1
by: Jeff S | last post by:
I would like to provide users with a text box in which they can enter a bunch of text (200 bytes or so). I would like to subsequently programmatically determine which text the user has selected. ...
3
by: gordonfmoore | last post by:
Hi, for some reason? I learnt it was sensible/useful to put any parameters that I wanted users to be able to change in the global.asax file. So my code would look like: //in my page load...
7
by: brendan.wong | last post by:
hello. i have a really simple form that asks the user to select a Month from a dropdown. the first time a user visits the page, the highlighted option should be October, which works fine. then,...
9
spider1916
by: spider1916 | last post by:
I am using the common dialog control to allow my users to select any printer available to them. The code I am using keeps changing the selected printer to the default printer............I don't...
1
by: bernies | last post by:
I am receiving a feed of data that is already coming out in a report type format. I receive this file as a text file. I need to be able to prompt the user for parameters (Beg Date / End Date /...
9
helimeef
by: helimeef | last post by:
Hi, I am trying to create a little JavaScript WYSIWYG editor much like the one I'm using to write this thread right now. I have almost enough knowledge of the language to create one. My only question...
1
by: ghjk | last post by:
I'm developing web site using php and mysql. In there user has to select a date, and data belongs to that date should print.My date field type is datetime. This is my code and it is not...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
4
by: coder86 | last post by:
Hi, I am new to this site . I am looking for some help in updating my database from the value selected by user. Heres my page I have a table with rows of ID and its status. Status is a drop...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.