Tuesday, 15 April 2014

Comparing data type of sql server and ms access in c#






Jet Engine (Access)   Sql-Server                            C#
Text                  char, nchar, varchar, nvarchar        string
Memo                  text, ntext, the above with len>255   string
Byte                  tinyint                               byte
Integer               smallint                              short
Long Integer          integer (int)                         int
Single                real                                  float
Double                float                                 double
Replication ID        float                                 Guid
Decimal               decimal                               decimal
Date/Time             smalldatetime, datetime, datetime2    DateTime
Binary     (8 bytes)  timestamp, rowversion (Since V2008)   byte[]    (8 bytes)
Currency              smallmoney, money                     decimal
AutoNumber            int + identity property               int
Yes/No                bit                                   bool
OLE Object            image                                 byte[]
Hyperlink             <no equivalent>                       string
<no equivalent>       binary, varbinary                     byte[]

Friday, 11 April 2014

Delete All File in Folder from "*.bak" Format File

Method 1:
DECLARE @DateString CHAR(8)
SET @DateString = '04/10/2014'
EXECUTE master.dbo.xp_delete_file 0,  N'E:\10-04-2014\',N'bak',@DateString, 1

 
Method 2:


EXEC sp_configure 'show advanced options', 1
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO

EXECUTE master.dbo.xp_cmdshell  'del E:\10-04-2014\Test_db.bak'

Create Folder

EXEC master.dbo.xp_create_subdir '<path>'

Ex: EXEC master.dbo.xp_create_subdir 'E:\10-04-2014\'

How to list files inside a folder with SQL Server

EXEC xp_dirtree '<path>', 10, 1

EX: EXEC xp_dirtree 'E:\10-04-2014\', 10, 1

Get All Sup dir in folder

EXEC master.sys.xp_subdirs 'e:\\'

EXEC master.sys.xp_dirtree 'E:\',1,1;