- @echo off
- set hh=%time:~-11,2%
- set /a hh=%hh%+100
- set hh=%hh:~1%
- set dateseed=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%
- %time:~3,2%%time:~6,2%
- if not exist "\\140.175.165.10\Sharing\Databasebackup\
- %dateseed%" mkdir "\\140.175.165.10\Sharing
- \Databasebackup\%dateseed%"
- copy D:\HELLO "\\140.175.165.10\Sharing\Databasebackup\
- %dateseed%"
Monday, 12 December 2016
DOS Command (CMS) Create Folder Current Datetime and Move Files Shared Folder
Friday, 9 December 2016
How to Use While LOOP in SQL
- DECLARE @TOTALV BIGINT
- DECLARE @InitialValue BIGINT
- SET @InitialValue=1
- SET @TOTALV=12
- WHILE (@InitialValue<=@TOTALV)
- BEGIN
- print @InitialValue
- SET @InitialValue=@InitialValue+1
- END
Tuesday, 6 December 2016
SQL Function Get Total Time in HH:MM:SS
- CREATE FUNCTION [dbo].TotalTime
- (
- @StartTime DATETIME,
- @EndTime DATETIME
- )
- RETURNS Varchar(10)
- AS
- begin
- DECLARE @D VARCHAR(400)='31784'
- Declare @outTime Varchar(10);
- SELECT @D = DATEDIFF(SECOND,@StartTime,@EndTime)
- SELECT @outTime =CONVERT(VARCHAR(5), @D/60/60)
- + ':' + RIGHT('0' + CONVERT(VARCHAR(2), @D/60%60), 2)
- + ':' + RIGHT('0' + CONVERT(VARCHAR(2), @D % 60), 2)
- RETURN @outTime
- END
- GO
- SELECT dbo.TotalTime('2016-08-10 10:36:01.000','2016-08-10 19:25:45.000')
How to remove empty lines in text In Visual
Visual Studio has ability to delete empty lines in replace operation using regular expressions.
- Click Ctrl-H (quick replace)
- Tick "Use Regular Expressions"
- In Find specify
^$\n
- In Replace box delete everything.
- Click "Replace All"
All empty lines will be deleted.
Regular expression for empty line consist of
Beginning of line
^
End of line
$
Line break
\n
SQL Group With Group Total
- SELECT isnull(WO_status,0) as WO_status,
- (case when MwO.WO_status=1 then 'Open' when MwO.WO_status=2 then 'Close' when MWO.WO_status=3 Then 'Short Close'
- when MwO.WO_status=4 then 'Cancel'
- else 'Total' end) as statusR,
- count(*) as countValue
- FROM M_WorkOrder MwO
- inner join M_WorkorderDetails MwOd on MwO.WOID=MwOd.WOD_WOID
- INNER join BILL_KEYWORD BK on BK.id=MwOd.WOD_KEYID
- INNER join billing_from bf on bf.id=MwO.WO_CID
- where (MwOd.WOD_CUserID=15 or 15 =0 )
- group by WO_status WITH ROLLUP
Copy All tables with Data in Another Database
- CREATE PROCEDURE [dbo].[uspCreateCopyTables]-- GOALTEST,GOAL
- -- parameters for the stored procedure here
- @toDatabase VARCHAR(100)
- ,@fromDatabase VARCHAR(100)
- AS
- BEGIN
- -- SET NOCOUNT ON added to prevent extra result sets from
- SET NOCOUNT ON;
- DECLARE @fullTableList VARCHAR(8000);
- DECLARE @idx INT;
- DECLARE @tableName VARCHAR(8000);
- DECLARE @SQLQuery NVARCHAR(500);
- DECLARE @ParameterDefinition NVARCHAR(100);
- -- this query gives the list of table name existing in the database.
- SELECT @fullTableList = ISNULL(@fullTableList + ',' + TABLE_NAME, TABLE_NAME)
- FROM INFORMATION_SCHEMA.TABLES
- WHERE TABLE_TYPE = 'BASE TABLE';
- SELECT @idx = 1
- /* this section splits the table name from comma separated string and copies that table name from
- one database to another database*/
- IF LEN(@fullTableList) > 1
- OR @fullTableList IS NOT NULL
- WHILE @idx != 0
- BEGIN
- SET @idx = CHARINDEX(',', @fullTableList)
- IF @idx != 0
- SET @tableName = LEFT(@fullTableList, @idx - 1)
- ELSE
- SET @tableName = @fullTableList
- IF (LEN(@tableName) > 0)
- SET @SQLQuery = 'SELECT * INTO [' + @toDatabase + '].[dbo].[' + @tableName + '] FROM [' + @fromDatabase + '].[dbo].[' + @tableName + ']'
- EXEC (@SQLQuery)
- SET @fullTableList = RIGHT(@fullTableList, LEN(@fullTableList) - @idx)
- IF LEN(@fullTableList) = 0
- BREAK
- END
- END
- GO
Subscribe to:
Posts (Atom)
Upload valid file in C#
protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile) { try { Dictionary<string, byte[]...
-
Setting Header Programatically You can also set the cache headers programmatically. This can be useful for generated content and allows m...
-
CREATE TABLE dbo.M_Bank ( ID INT IDENTITY NOT NULL, MB_NAME NVARCHAR (50), MB_SNAME NVARCHAR (20), MB_ADDUSER ...
-
SELECT distinct(volume_mount_point), total_bytes/1048576 as Size_in_MB, total_bytes/1048576/1024 as Size_in_GB, available_bytes/1048576 ...