August 27, 2009

SQL Server: String (character) datatype

Non-Unicode

  1. char(n) : Fixed-length string with Maximum 8,000 characters

  2. varchar(n) : Variable-length string with Maximum 8,000 characters

  3. varchar(max) : Variable-length string with Maximum 1,073,741,824 characters

  4. Text : Variable-length string with Maximum 2GB of text data or maximum length of 2^31 - 1 characters


Unicode

  1. nchar(n) : Fixed-length Unicode data with Maximum 4,000 characters.

  2. nvarchar(n) : Variable-length Unicode data with Maximum 4,000 characters.

  3. nvarchar(max): Variable-length Unicode data with Maximum 536,870,912 characters.

  4. ntext : Variable-length Unicode data. Maximum 2GB of text data or a maximum length of 2^30 - 1 characters

August 20, 2009

Sql Server : Change Column & Table Name

Change Column Name :-
sp_RENAME 'TableName.OldColumnName', 'NewColumnName' , 'COLUMN'


Example:
'TableName.OldColumnName' Variables
'NewColumnName' Variables
'COLUMN' is Fixed value.


Change Table Name :-

sp_RENAME 'oldTableName, 'NewTableName'

August 19, 2009

VB 6.0: Write/Append log in text file

Public Sub ErrorInFile(ModuleName As String, FunctionName As String, ErrorDesc As String)
Dim iFileNumberWrite As Integer, str As String
iFileNumberWrite = FreeFile
str = ""
str = str & "On DateTime : " & Format(Now, "dd-MMM-yyyy HH:mm:ss") & vbCrLf
str = str & "Module Name : " & ModuleName & vbCrLf
str = str & "Function Name : " & FunctionName & vbCrLf
str = str & "Error Description : " & ErrorDesc & vbCrLf
str = str & "----------------------------------------------------" & vbCrLf
Open App.Path & "\Error.Log" For Append As iFileNumberWrite
Print #iFileNumberWrite, str
Close #iFileNumberWrite
End Sub