473,405 Members | 2,344 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,405 software developers and data experts.

how Create sql like Query with dynamic

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[SelectResultAllDatails]
  2.  
  3. AS
  4. BEGIN
  5.  
  6. DECLARE @query nvarchar(max), @VALUE NVARCHAR(10)
  7.  
  8. SET @VALUE = 'D013'
  9.  
  10. SET @QUERY = 'select * from dbo.ResultsDetails where [Student Index] LIKE ''' + @VALUE + '%''' 
  11.  
  12. SELECT @query
  13.  
  14. END
  15. GO
Jun 28 '14 #1
1 1143
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Use an input parameter. You can read more about creating procedures from microsoft's documentation: http://msdn.microsoft.com/en-us/library/ms187926.aspx. You also shouldn't build a SQL string that way, it's subject to SQL injection attacks.
Jun 29 '14 #2

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

Similar topics

1
by: wongz | last post by:
Hi, i m trying to create a dynamic buttons based on the user right. I manage to code this whole stuff in web application. Unfortunately i m trying to write this code in window application it cant...
3
by: WHY | last post by:
Since there's no way to create a c# method with optional, or nullable parameters. And since you can't write an overloaded web method. Is it possible to edit the WSDL in conjunction with a c#...
2
by: naijacoder naijacoder | last post by:
Hi All, Any ideas on how to create a dynamic TreeView Menu with user roles.For example binding XML to Treeview or populated from DataBase.. Thx *** Sent via Developersdex...
1
by: Russell Mangel | last post by:
Sorry about the Cross-Post, I posted my question in the wrong group. Hello, What is the simplest way to create a dynamic collection (during run-time), using basic C (Struct data types). Since...
2
by: mael.iosa | last post by:
Hi, I'm new to this group and fairly new to Access. I have a bunch of data, and after several other queries, I generate the following query which has two fields: Bin, Time 20 3.5 20 3.9 20...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
0
by: karthkeyanmani | last post by:
Hi all, I want to create a dynamic data structure (ie) getting the data from database, using this data's (not fixed) create a dynamic structure, and access these data's somewhere. Thank you.
6
by: Peter Herath | last post by:
I want to create a dynamic report using a crosstab query...... pls someone look into my attached example database and help me out to do the report generation.... example is like dis...: there...
2
by: lucky m | last post by:
Hi.. I am displaying database table on the form. Now i want to create a dynamic check box(it should place a checkbox for each row).If i check the check box it will add to database.. Can anyone...
5
by: wizardry | last post by:
Hello - I'm trying to create a dynamic results table layout from 4 tables. I want to have the data from the 2 tables asstatusupdate and asstatusdata even if the other two tables do not have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.