Click here to Skip to main content
15,919,028 members
Home / Discussions / Database
   

Database

 
QuestionSQL and C# problem [modified] Pin
William Ten Broek24-Aug-06 11:30
William Ten Broek24-Aug-06 11:30 
AnswerLDAP Pin
Ennis Ray Lynch, Jr.24-Aug-06 11:33
Ennis Ray Lynch, Jr.24-Aug-06 11:33 
QuestionHow to do a Select/Where x=NULL Pin
TheJudeDude24-Aug-06 11:09
TheJudeDude24-Aug-06 11:09 
AnswerRe: How to do a Select/Where x=NULL Pin
Colin Angus Mackay24-Aug-06 11:19
Colin Angus Mackay24-Aug-06 11:19 
GeneralRe: How to do a Select/Where x=NULL Pin
TheJudeDude24-Aug-06 11:25
TheJudeDude24-Aug-06 11:25 
AnswerRe: How to do a Select/Where x=NULL Pin
S Pandian25-Aug-06 22:37
S Pandian25-Aug-06 22:37 
QuestionProgramming SQL Database Question Pin
Jethro6324-Aug-06 10:11
Jethro6324-Aug-06 10:11 
AnswerRe: Programming SQL Database Question Pin
Colin Angus Mackay24-Aug-06 11:23
Colin Angus Mackay24-Aug-06 11:23 
Jethro63 wrote:
But what if the table does not yet exist? What if the purpose of the procedure in question is to check for existence of a certain table and create it if its not there?


You can put just about any SQL commands you like into a SqlCommand. So if you can write it in Query Analyser you can pretty much shove it in a SqlCommand too. The exception is "GO" which is a preprocessor symbol used by Query Analyser to tell it where to split the statements into separate batches. In .NET, the equivalent is to split the SQL up into separate SqlCommands.

So, to check if a table exists:

IF EXISTS (SELECT * FROM INFORMATION_SCHEME.TABLES WHERE TABLE_NAME = 'MyTableName')
BEGIN
    -- Do stuff based on the existance of the table
END
ELSE
BEGIN
    -- Do stuff based on the nonexistance of the table
END



GeneralRe: Programming SQL Database Question Pin
Jethro6327-Aug-06 21:22
Jethro6327-Aug-06 21:22 
GeneralRe: Programming SQL Database Question Pin
Colin Angus Mackay27-Aug-06 21:51
Colin Angus Mackay27-Aug-06 21:51 
GeneralRe: Programming SQL Database Question Pin
Jethro6329-Aug-06 3:05
Jethro6329-Aug-06 3:05 
GeneralRe: Programming SQL Database Question Pin
Colin Angus Mackay29-Aug-06 11:23
Colin Angus Mackay29-Aug-06 11:23 
GeneralRe: Programming SQL Database Question Pin
Jethro6331-Aug-06 3:17
Jethro6331-Aug-06 3:17 
GeneralRe: Programming SQL Database Question Pin
Colin Angus Mackay31-Aug-06 8:49
Colin Angus Mackay31-Aug-06 8:49 
GeneralRe: Programming SQL Database Question Pin
Jethro6331-Aug-06 9:13
Jethro6331-Aug-06 9:13 
QuestionPage Performance Pin
Amit Kumar G24-Aug-06 7:41
Amit Kumar G24-Aug-06 7:41 
AnswerDon't recache the data Pin
Ennis Ray Lynch, Jr.24-Aug-06 10:35
Ennis Ray Lynch, Jr.24-Aug-06 10:35 
QuestionConnector/Net 5.0.0 and Attributes Pin
knoppis24-Aug-06 6:42
knoppis24-Aug-06 6:42 
GeneralImport Data Into SQL Server 2005 Express Pin
Bassam Abdul-Baki24-Aug-06 6:36
professionalBassam Abdul-Baki24-Aug-06 6:36 
GeneralRe: Import Data Into SQL Server 2005 Express Pin
Mike Dimmick24-Aug-06 12:19
Mike Dimmick24-Aug-06 12:19 
GeneralRe: Import Data Into SQL Server 2005 Express Pin
Bassam Abdul-Baki25-Aug-06 2:49
professionalBassam Abdul-Baki25-Aug-06 2:49 
QuestionHow do I write this query? Pin
netDeveloper24-Aug-06 1:00
netDeveloper24-Aug-06 1:00 
AnswerRe: How do I write this query? Pin
Colin Angus Mackay24-Aug-06 2:17
Colin Angus Mackay24-Aug-06 2:17 
Questionexport dataset to excel?? Pin
steven_wong23-Aug-06 23:21
steven_wong23-Aug-06 23:21 
QuestionStored Proc Error help. Pin
vipinpaliwal198023-Aug-06 21:04
vipinpaliwal198023-Aug-06 21:04 

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.