473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

MS SQL - User Selected Parameters

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 2309
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

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...
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. ...
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...
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,...
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...
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 /...
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...
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...
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...
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...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
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...

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.