Click here to Skip to main content
15,887,267 members
Home / Discussions / Database
   

Database

 
AnswerRe: ADV ICE WANTED!! Pin
Colin Angus Mackay28-Oct-05 13:19
Colin Angus Mackay28-Oct-05 13:19 
QuestionProblem with working SQL Server SAVE POINTS in Transactions. Pin
farhan197627-Oct-05 20:11
farhan197627-Oct-05 20:11 
QuestionTriggers and transaction context. Pin
devvvy27-Oct-05 6:15
devvvy27-Oct-05 6:15 
AnswerRe: Triggers and transaction context. Pin
Farhan Noor Qureshi27-Oct-05 9:21
Farhan Noor Qureshi27-Oct-05 9:21 
GeneralRe: Triggers and transaction context. Pin
devvvy27-Oct-05 13:49
devvvy27-Oct-05 13:49 
QuestionDatabase 'foodmart 2000' does not exist Pin
kuldeep_kumar27-Oct-05 5:25
kuldeep_kumar27-Oct-05 5:25 
QuestionDynamic procedures, are they possible? Pin
FruitBatInShades27-Oct-05 3:59
FruitBatInShades27-Oct-05 3:59 
AnswerRe: Dynamic procedures, are they possible? Pin
Colin Angus Mackay27-Oct-05 6:31
Colin Angus Mackay27-Oct-05 6:31 
You can do this with clever use of AND/OR clauses

Select Top 5 BusinessID
FROM SELECT TOP 5 fbisBusinessLookup.BusinessID
FROM fbisBusinessLookup INNER JOIN
DIRECTORY ON fbisBusinessLookup.BusinessID = directory.[id]
WHERE ((@country <= 0) OR (@country > 0 AND fbisBusinessLookup.countyid = @County))
AND ((@Town <= 0) OR (@Town > 0 AND fbisBusinessLookup.TownID = @Town))
AND ((@Type <= 0) OR (@Type > 0 AND fbisBusinessLookup.TypeID = @Type))
ORDER BY NEWID()) DERIVEDTBL


Note, the above doesn account for nulls in @country, @Town or @Type.

You can also declare a large enough varchar and concatenate a SQL command together then use EXEC(@sqlString) However, if you can do without that then I'd recommend it because there is a security risk in building a SQL command and executing it dynamically.

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


AnswerRe: Dynamic procedures, are they possible? Pin
codet28-Oct-05 16:28
codet28-Oct-05 16:28 
QuestionProblems inserting data in database with datagrid Pin
wappi_berlin27-Oct-05 1:44
wappi_berlin27-Oct-05 1:44 
QuestionExcluding some fields from a table in a datagrid Pin
odrap26-Oct-05 0:24
odrap26-Oct-05 0:24 
AnswerRe: Excluding some fields from a table in a datagrid Pin
Edbert P26-Oct-05 12:50
Edbert P26-Oct-05 12:50 
QuestionInsert Data via Stored procedure by ado.net Pin
thedom225-Oct-05 23:33
thedom225-Oct-05 23:33 
AnswerRe: Insert Data via Stored procedure by ado.net Pin
Edbert P26-Oct-05 12:52
Edbert P26-Oct-05 12:52 
GeneralRe: Insert Data via Stored procedure by ado.net Pin
thedom226-Oct-05 13:16
thedom226-Oct-05 13:16 
QuestionCreating a Microsoft Acces &quot;Module&quot; in a MDB-file by Code from C++ Pin
Uwe Keim25-Oct-05 20:08
sitebuilderUwe Keim25-Oct-05 20:08 
AnswerRe: Creating a Microsoft Acces &quot;Module&quot; in a MDB-file by Code from C++ Pin
Uwe Keim25-Oct-05 20:33
sitebuilderUwe Keim25-Oct-05 20:33 
QuestionQuery Tables Fiels name and type Pin
icDavid25-Oct-05 13:12
icDavid25-Oct-05 13:12 
AnswerRe: Query Tables Fiels name and type Pin
icDavid25-Oct-05 14:27
icDavid25-Oct-05 14:27 
AnswerRe: Query Tables Fiels name and type Pin
Farhan Noor Qureshi25-Oct-05 17:59
Farhan Noor Qureshi25-Oct-05 17:59 
QuestionAggregate queries and functions Pin
mjackson1125-Oct-05 10:53
mjackson1125-Oct-05 10:53 
AnswerRe: Aggregate queries and functions Pin
Farhan Noor Qureshi25-Oct-05 12:38
Farhan Noor Qureshi25-Oct-05 12:38 
GeneralRe: Aggregate queries and functions Pin
mjackson1125-Oct-05 18:25
mjackson1125-Oct-05 18:25 
GeneralRe: Aggregate queries and functions Pin
Farhan Noor Qureshi26-Oct-05 11:35
Farhan Noor Qureshi26-Oct-05 11:35 
QuestionHiiSQL Server Database Name Pin
utsav_verma24-Oct-05 19:48
utsav_verma24-Oct-05 19:48 

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.