Conditional WHERE Clauses and Boolean Algebra
Utilize simple boolean algebra and nullable parameters to implement conditional WHERE clauses without dynamic SQL.
2010-08-31
17,797 reads
Utilize simple boolean algebra and nullable parameters to implement conditional WHERE clauses without dynamic SQL.
2010-08-31
17,797 reads
Here it is: RESTORE HEADERONLY FROM disk = 'D:\ONEC\ONEC_diff.BAK' -------------------------------------------- BackupName,BackupDescription,BackupType,ExpirationDate,Compressed,Position,DeviceType,UserName,ServerName,DatabaseName,DatabaseVersion,DatabaseCreationDate,BackupSize,FirstLsn,LastLsn,CheckpointLsn,DifferentialBaseLsn,BackupStartDate,BackupFinishDate,SortOrder,CodePage,UnicodeLocaleId,UnicodeComparisonStyle,CompatibilityLevel,SoftwareVendorId,SoftwareVersionMajor,SoftwareVersionMinor,SoftwareVersionBuild,MachineName,Flags,BindingId,RecoveryForkId,Collation ,,5,,0,1,2,DOMAIN.CENTER\sql_admin,SPICA,ONEC,539,2001-10-06 14:15:37.000,43902976,1113000000026400011,1113000000026900001,1113000000026400011,1112000000320600011,2003-07-17 13:34:27.000,2003-07-17 13:34:41.000,106,227,1033,196609,80,4608,8,0,760,SPICA,0,{25F1C387-968E-11D3-8CCC-0090278CBDBB},{59362432-EF65-410B-AB37-174F07E01A37},SQL_Latin1_General_CP1251_CI_AS (1 row(s) affected) ===================================================== RESTORE HEADERONLY FROM disk = 'D:\ONEC\ONEC.TLF' ----------------------------------------------------- BackupName,BackupDescription,BackupType,ExpirationDate,Compressed,Position,DeviceType,UserName,ServerName,DatabaseName,DatabaseVersion,DatabaseCreationDate,BackupSize,FirstLsn,LastLsn,CheckpointLsn,DifferentialBaseLsn,BackupStartDate,BackupFinishDate,SortOrder,CodePage,UnicodeLocaleId,UnicodeComparisonStyle,CompatibilityLevel,SoftwareVendorId,SoftwareVersionMajor,SoftwareVersionMinor,SoftwareVersionBuild,MachineName,Flags,BindingId,RecoveryForkId,Collation ,,2,,0,1,2,DOMAIN.CENTER\sql_admin,SPICA,ONEC,539,2001-10-06 14:15:37.000,2156032,1112000000094700001,1112000000499500001,1112000000440000009,1112000000320600011,2003-07-17 12:45:00.000,2003-07-17 12:45:01.000,106,227,1033,196609,80,4608,8,0,760,SPICA,0,{25F1C387-968E-11D3-8CCC-0090278CBDBB},{59362432-EF65-410B-AB37-174F07E01A37},SQL_Latin1_General_CP1251_CI_AS ,,2,,0,2,2,DOMAIN.CENTER\sql_admin,SPICA,ONEC,539,2001-10-06 14:15:37.000,647168,1112000000499500001,1112000000609100001,1112000000440000009,1112000000320600011,2003-07-17 13:00:00.000,2003-07-17 13:00:01.000,106,227,1033,196609,80,4608,8,0,760,SPICA,0,{25F1C387-968E-11D3-8CCC-0090278CBDBB},{59362432-EF65-410B-AB37-174F07E01A37},SQL_Latin1_General_CP1251_CI_AS ,,2,,0,3,2,DOMAIN.CENTER\sql_admin,SPICA,ONEC,539,2001-10-06 14:15:37.000,122880,1112000000609100001,1112000000615900001,1112000000440000009,1112000000320600011,2003-07-17 13:14:59.000,2003-07-17 13:15:01.000,106,227,1033,196609,80,4608,8,0,760,SPICA,0,{25F1C387-968E-11D3-8CCC-0090278CBDBB},{59362432-EF65-410B-AB37-174F07E01A37},SQL_Latin1_General_CP1251_CI_AS ,,2,,0,4,2,DOMAIN.CENTER\sql_admin,SPICA,ONEC,539,2001-10-06 14:15:37.000,253952,1112000000615900001,1112000000641700001,1112000000440000009,1112000000320600011,2003-07-17 13:30:00.000,2003-07-17 13:30:01.000,106,227,1033,196609,80,4608,8,0,760,SPICA,0,{25F1C387-968E-11D3-8CCC-0090278CBDBB},{59362432-EF65-410B-AB37-174F07E01A37},SQL_Latin1_General_CP1251_CI_AS ,,2,,0,5,2,DOMAIN.CENTER\sql_admin,SPICA,ONEC,539,2001-10-06 14:15:37.000,975872,1112000000641700001,1113000000167200001,1113000000026400011,1112000000320600011,2003-07-17 13:45:00.000,2003-07-17 13:45:01.000,106,227,1033,196609,80,4608,8,0,760,SPICA,0,{25F1C387-968E-11D3-8CCC-0090278CBDBB},{59362432-EF65-410B-AB37-174F07E01A37},SQL_Latin1_General_CP1251_CI_AS (5 row(s) affected)
2003-07-17
1 reads
An alternative to delete all those records is DELETE MyTable FROM MyTable t1 INNER JOIN MyTable t2 ON t1.Unique_ID = t2.Unique_ID AND t1.DateField < t2.DateField This will delete all the records for a single Unique_ID, except for the one with the latest date.
2003-07-17
thanks everyone... I found the solution. if I pass an empty string instead of the null value, it gives a return... Anne
2003-07-16
quote: Thanks all for valuable suggestion,Actually i want to install sql server 2000 first,than my database and after that my application which is a exe file.All this i want from CD to my laptop in a single click.I want all this for demo purpose. If this is for a demo, you shouldn't need a full […]
2003-06-27
This month’s T-SQL Tuesday is hosted by a dear friend, long time SQL Server...
By Steve Jones
I almost missed this month, so this is also a good #SQLNewBlogger post. I...
By Steve Jones
I had a lot of local branches for a repo (actually a few repos)....
Comments posted to this topic are about the item 7 sept, scheduled book
Comments posted to this topic are about the item 7 sept, schedlued article
Comments posted to this topic are about the item 6 sept, published book
Azure Data Lake Storage Gen 2 is built on ...?
See possible answers