Forum Discussion
Parameterizing SQL Select
Do you know the meaning of the master database?
I highly recommend you to stop all you do as soon as you can, until you fully understand, since you are working with the master database and anything you do can have a huge impact on your entire server including all databases!
The master database is a system database which records all the system-level information for a SQL Server system. You should not use it for storing your data!
According your code you are using the master database as it was a user database. Your first step should be to create a database and work only on your user databases (databases which you create)
Regarding the code
(1) I did not read the entire code since there is no reason for it before you provide the information to execute it, but I did noticed an issue in the first line. When you create SP then the variable should be separated with comma
(2) To be able to execute your code we need to have the relevant objects. please provide:
- Queries to CREATE your table(s) including indexes
- Queries to INSERT sample data.
- The desired result given the sample, as text or image of excel for example.
- A short description of the business rules, and how you got 1-2 of the results
- Which version of SQL Server you are using (this will help to fit the query to your version).
Regards,