Click here to Skip to main content
15,900,457 members
Home / Discussions / Database
   

Database

 
AnswerRe: delegate array of controls Pin
CHill602-Apr-16 9:56
mveCHill602-Apr-16 9:56 
QuestionMigrate data from production database to testing database Pin
Member 124302851-Apr-16 0:28
Member 124302851-Apr-16 0:28 
AnswerRe: Migrate data from production database to testing database Pin
Wombaticus1-Apr-16 1:19
Wombaticus1-Apr-16 1:19 
AnswerRe: Migrate data from production database to testing database Pin
CHill601-Apr-16 4:55
mveCHill601-Apr-16 4:55 
QuestionIs there an API for Datastax's cassandra file system (similar to WebHDFS). Pin
ravitk30-Mar-16 13:11
ravitk30-Mar-16 13:11 
QuestionStar schema . Pin
Member 1242471629-Mar-16 18:35
Member 1242471629-Mar-16 18:35 
AnswerRe: Star schema . Pin
GuyThiebaut29-Mar-16 21:55
professionalGuyThiebaut29-Mar-16 21:55 
QuestionTake default value if column doesn't exist Pin
indian14329-Mar-16 6:22
indian14329-Mar-16 6:22 
Hi All,

I am writing a Dynamic Sql in a while loop which loop through all Tables and then columns in ever table, I have written a general Dynamic sql to read the columns but some tables do not have CreatedBy and ModifiedBy columns and when it is getting executed the Dynamic Sql is failing for some of the scenarios.

Can somebody suggest me how to write that Dynamic Sql to fit for both the scenarios. Any suggestion is helpful thanks in advance.

Here is my Dynamic sql
SET @sql =N'INSERT INTO TrackUpdatedColumnNamesFlatTable (TableName, ColumnName, PrimaryKeyColumnName, PrimaryKeyValue, TransactionId
    , TransactionType, CreatedBy, ModifiedBy, CreatedDate, ModifiedDate, IsSoftDelete, IsCmsActive, ColumnValueAfter)
    select ''' + @TblName + ''', ''' +  @ColName + ''', ''' +  @PKColName + '''
    , ' +  @PKColName + ', $start_lsn , CASE WHEN ($operation=1) THEN ''Delete''
    WHEN $operation=2 THEN ''Insert''
    WHEN __$operation=4 THEN ''Update''
    END TransactionType, CreatedBy, ModifiedBy, CreatedDate, ModifiedDate
    , ' + CAST(@IsDeleted AS varchar(max)) + '
    , ' + CAST(@IsCmsActive AS varchar(max)) + '
    , CASE WHEN __$operation=1 THEN NULL ELSE CAST(' + @ColName + ' AS nvarchar(max)) END<br />
FROM [cdc].' + @cdcinstancename
+ ' WHERE CAST(sys.fn_cdc_map_lsn_to_time($start_lsn) AS DATE)=CAST(''' + @DateToTrack + ''' AS DATE)
AND sys.fn_cdc_is_bit_set(sys.fn_cdc_get_column_ordinal(''' + @captureinstance +
''',''' + '' + @ColName + '''), __$update_mask) = 1
AND __$operation IN (1, 2, 4)';

exec sp_executesql @sql, N'@IsColumnModified int out', @IsColumnModified out
Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

AnswerRe: Take default value if column doesn't exist Pin
CHill6029-Mar-16 13:44
mveCHill6029-Mar-16 13:44 
QuestionDate time so confuse. Pin
hmanhha29-Mar-16 5:25
hmanhha29-Mar-16 5:25 
AnswerRe: Date time so confuse. Pin
CHill6029-Mar-16 13:46
mveCHill6029-Mar-16 13:46 
GeneralRe: Date time so confuse. Pin
hmanhha29-Mar-16 15:28
hmanhha29-Mar-16 15:28 
Questionoracle not allow date field with same name "Date" Pin
Asif Rehman28-Mar-16 21:51
Asif Rehman28-Mar-16 21:51 
AnswerRe: oracle not allow date field with same name "Date" PinPopular
GuyThiebaut28-Mar-16 22:30
professionalGuyThiebaut28-Mar-16 22:30 
AnswerRe: oracle not allow date field with same name "Date" Pin
Jörgen Andersson28-Mar-16 23:07
professionalJörgen Andersson28-Mar-16 23:07 
SuggestionRe: oracle not allow date field with same name "Date" PinPopular
Sascha Lefèvre28-Mar-16 23:49
professionalSascha Lefèvre28-Mar-16 23:49 
QuestionHow to deploy a reporting project into report server (ssrs) through visual 2015 Pin
jonatan_55624-Mar-16 0:01
jonatan_55624-Mar-16 0:01 
RantREPOST Pin
Richard Deeming24-Mar-16 2:16
mveRichard Deeming24-Mar-16 2:16 
AnswerRe: How to deploy a reporting project into report server (ssrs) through visual 2015 Pin
GuyThiebaut25-Mar-16 23:19
professionalGuyThiebaut25-Mar-16 23:19 
GeneralRe: How to deploy a reporting project into report server (ssrs) through visual 2015 Pin
jonatan_55614-Apr-16 12:33
jonatan_55614-Apr-16 12:33 
GeneralRe: How to deploy a reporting project into report server (ssrs) through visual 2015 Pin
GuyThiebaut14-Apr-16 21:54
professionalGuyThiebaut14-Apr-16 21:54 
QuestionWait until an operation finished Pin
indian14323-Mar-16 6:44
indian14323-Mar-16 6:44 
AnswerRe: Wait until an operation finished Pin
John C Rayan24-Mar-16 6:27
professionalJohn C Rayan24-Mar-16 6:27 
GeneralRe: Wait until an operation finished Pin
indian14324-Mar-16 9:50
indian14324-Mar-16 9:50 
GeneralRe: Wait until an operation finished Pin
GuyThiebaut25-Mar-16 23:33
professionalGuyThiebaut25-Mar-16 23:33 

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.