Click here to Skip to main content
15,892,537 members
Home / Discussions / Database
   

Database

 
Questionabout SQL ... Pin
mostafa_h8-Sep-05 9:25
mostafa_h8-Sep-05 9:25 
AnswerRe: about SQL ... Pin
Colin Angus Mackay8-Sep-05 10:57
Colin Angus Mackay8-Sep-05 10:57 
GeneralRe: about SQL ... Pin
mostafa_h8-Sep-05 15:24
mostafa_h8-Sep-05 15:24 
GeneralRe: about SQL ... Pin
Colin Angus Mackay8-Sep-05 20:08
Colin Angus Mackay8-Sep-05 20:08 
GeneralRe: about SQL ... Pin
mostafa_h14-Sep-05 20:17
mostafa_h14-Sep-05 20:17 
GeneralRe: about SQL ... Pin
Colin Angus Mackay14-Sep-05 20:29
Colin Angus Mackay14-Sep-05 20:29 
GeneralRe: about SQL ... Pin
mostafa_h14-Sep-05 21:19
mostafa_h14-Sep-05 21:19 
GeneralRe: about SQL ... Pin
Colin Angus Mackay15-Sep-05 2:47
Colin Angus Mackay15-Sep-05 2:47 
To use a variable in SQL you must declare it first, then you can use it.

e.g.
-- First declare the variable
DECLARE @myIntegerVariable int
 
-- Now it can be used.
SET @myIntegerVariable = 12;

-- To get the result of a column in a SELECT statement that returns just one row. 
SELECT @myIntegerVariable = COUNT(*) FROM MyTable;
 
-- To use as a filter in a SELECT statement
SELECT * FROM MyTable WHERE MyColumn = @myIntergerVariable


If the variable is arriving as a parameter into a stored procedure, then the definition of the procedure declared the varibale implicitly. e.g.
CREATE PROCEDURE dbo.MyProc
@myFirstParameter int,
@mySecondParameter varchar(20)
AS
-- Do the processing of the Stored Procedure
GO


In C# you can supply varibles as parameters to any SQL in the SqlCommand.CommandText. This was the version that I showed you already in the example in my previous post.

Does this help?


My: Blog | Photos

"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious


GeneralRe: about SQL ... Pin
mostafa_h15-Sep-05 3:32
mostafa_h15-Sep-05 3:32 
QuestionDataGrid new row Pin
airbus3808-Sep-05 6:01
airbus3808-Sep-05 6:01 
AnswerRe: DataGrid new row Pin
enjoycrack8-Sep-05 23:51
enjoycrack8-Sep-05 23:51 
AnswerRe: DataGrid new row Pin
miah alom9-Sep-05 5:54
miah alom9-Sep-05 5:54 
QuestionMS Hierarchical FlexGrid Pin
pjhenry12168-Sep-05 5:32
pjhenry12168-Sep-05 5:32 
AnswerRe: MS Hierarchical FlexGrid Pin
smita_roy8-Sep-05 19:59
smita_roy8-Sep-05 19:59 
QuestionT-Sql problem Pin
WDI8-Sep-05 4:55
WDI8-Sep-05 4:55 
AnswerRe: T-Sql problem Pin
Colin Angus Mackay8-Sep-05 10:39
Colin Angus Mackay8-Sep-05 10:39 
GeneralRe: T-Sql problem Pin
Frank Kerrigan9-Sep-05 0:37
Frank Kerrigan9-Sep-05 0:37 
QuestionCall a variable from the another Form ... Pin
mostafa_h7-Sep-05 21:38
mostafa_h7-Sep-05 21:38 
AnswerRe: Call a variable from the another Form ... Pin
enjoycrack8-Sep-05 0:44
enjoycrack8-Sep-05 0:44 
GeneralRe: Call a variable from the another Form ... Pin
mostafa_h8-Sep-05 1:52
mostafa_h8-Sep-05 1:52 
GeneralRe: Call a variable from the another Form ... Pin
enjoycrack8-Sep-05 1:54
enjoycrack8-Sep-05 1:54 
GeneralRe: Call a variable from the another Form ... Pin
mostafa_h8-Sep-05 4:15
mostafa_h8-Sep-05 4:15 
GeneralRe: Call a variable from the another Form ... Pin
enjoycrack8-Sep-05 21:07
enjoycrack8-Sep-05 21:07 
GeneralRe: Call a variable from the another Form ... Pin
mostafa_h15-Sep-05 0:59
mostafa_h15-Sep-05 0:59 
GeneralRe: Call a variable from the another Form ... Pin
enjoycrack15-Sep-05 1:05
enjoycrack15-Sep-05 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.