i try to run SET-SPSecurityTokenServiceConfig command in powershell, but it return me error message
Solution
Add-PSSnapin Microsoft.SharePoint.Powershell
After this, sharepoint commands will be available in PowerShell.
SQL Tutorial, SQL Server, SQL Statement, SQL Query, MS SQL 2000 Reporting Service, T-SQL, SQL Function, SQL Syntax, SQL User Define Function, SQL Trigger
i try to run SET-SPSecurityTokenServiceConfig command in powershell, but it return me error message
Posted by Emil Chang at 2:14 AM 0 comments
If you imports excel file into database using sql query
INSERT INTO newtable
select * FROM
OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\temp.xls;HDR=YES', 'SELECT * FROM [sheet$]')
Posted by Emil Chang at 12:08 AM 0 comments
If you run below SQL statement
---------------------------------------------------------
Select * into DBTable FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=D:\myExcelFile.xlsx;HDR=YES', 'SELECT * FROM [Sheet1$]')
INSERT INTO DBTable select * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=D:\myExcelFile.xlsx;HDR=YES', 'SELECT * FROM [Sheet1$]')
--------------------------------------------------------
and you get an error message like below
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered
Solution
you need to download
"Data Connectivity Components for 2007 office system Driver".
after you download, please restart your server.
you can click link here to download from microsoft site.
you will able to saw your microsoft excel driver 12.0 in your Data Sources(ODBC) in control panel
Posted by Emil Chang at 7:58 AM 0 comments
Limited SQL Server 2000 DTS Functionality on 64-bit Operating Systems
Posted by Emil Chang at 1:54 AM 2 comments
you need to run one line per line, if you run all SQL together.
you will get below error message:
Incorrect syntax near 'sp_configure'
Please Follow below Step
Step 1: sp_configure 'show advanced options', 1
Output Message: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
Step 2: reconfigure
Output Message: Command(s) completed successfully.
Step 3: sp_configure 'Ad Hoc Distributed Queries', 1
Output Message: Configuration option 'Ad Hoc Distributed Queries' changed from 1 to 1. Run the RECONFIGURE statement to install.
Step 4: reconfigure
Output Message: Command(s) completed successfully.
Step 5: Run your SQL to import Excel Files
Insert Excel Data into New Table (Create New Table)
Posted by Emil Chang at 12:26 AM 1 comments
Error : Msg 15110, Level 16, State 1, Procedure sp_changedbowner, Line 46
The proposed new database owner is already a user in the database
If you are getting above error message while changing the database owner. ‘DBuser’ cannot become the owner of the current database if it already has access/dbo access to the database through an existing alias or user security account within the database. To avoid this, drop the alias or ‘user’ within the current database first. here is the solution.
Use Database_Name;
sp_dropuser ‘DBUser’
sp_changedbowner ‘DBUser’
Posted by Emil Chang at 4:44 AM 0 comments
Posted by Emil Chang at 4:36 AM 0 comments
DECLARE @myVar int SET @myVar = 5
DECLARE @myVar int = 5
exec sp_MySproc 'murphy,35;galen,31;samuels,27;colton,42'
CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int) DECLARE @myPeeps PeepsType INSERT @myPeeps SELECT 'murphy', 35 INSERT @myPeeps SELECT 'galen', 31 INSERT @myPeeps SELECT 'samuels', 27 INSERT @myPeeps SELECT 'colton', 42 exec sp_MySproc2 @myPeeps
CREATE PROCEDURE sp_MySproc2(@myPeeps PeepsType READONLY) ...
use of 3rd party add-ins like SQL Prompt ($195). But these tools are a horrible hack at best (e.g. they hook into the editor window and try to interpret what the application is doing). Posted by Emil Chang at 2:35 AM 0 comments
Below code is to show the unique value:
Public Sub LinqSample1()
Dim arrDistinct() = {1, 1, 1, 2, 2, 3, 4, 4, 5, 5}
Dim strUniqueFactors = arrDistinct.Distinct().Count()
Console.WriteLine(strUniqueFactors & " is unique value.")
End Sub
Result:
3 is unique value.
Posted by Emil Chang at 9:37 AM 0 comments
If you have ever taken raw user input and inserted it into a MySQL database there's a chance that you have left yourself wide open for a security issue known as SQL Injection.
SQL injection is someone inserting a SQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement that you will unknowingly run on your database.
for PHP users, All you need to do is use the function mysql_real_escape_string.
echo "Escaped Evil Injection:";
$name_evil = "'; DELETE FROM customers WHERE 1 or username = '";
$name_evil = mysql_real_escape_string($name_evil);
$query_evil = "SELECT * FROM customers WHERE username = '$name_evil'";
Result
Escaped Bad Injection:
SELECT * FROM customers WHERE username = '\'; DELETE FROM customers WHERE 1 or username = \''
Posted by Emil Chang at 8:15 AM 1 comments
When a server is in low memory situation, the Microsoft Distributed Transaction Coordinator (MS DTC) process (Msdtc.exe) may stop responding (crash).
When MS DTC tries to manage new transactions, the attempt fails because of a lack of resources.
Workaround
To work around this problem, verify that the memory configuration of the computer is correct, and then correct the memory configuration if it is not.
Microsoft Fix
To resolve this problem, obtain the latest service pack for Windows 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
Posted by Emil Chang at 8:30 AM 0 comments
Posted by Emil Chang at 1:08 AM 2 comments
I found this error message when i restore the database using the GUI and it appear this error message "Error 3154: The backup set holds a backup of a database other than the existing database"
It because of trying to restore database on an existing active database.
Solution:
RESTORE DATABASE DatabaseName
FROM DISK = 'C:\myDatabase.bak'
WITH REPLACE
Use WITH REPLACE when using RESTORE command when u saw above error message "Error 3154: The backup set holds a backup of a database other than the existing database"
Tested in MSSQL 2005
Posted by Emil Chang at 8:36 AM 1 comments
Returns the number of rows affected by the last statement. It will let you to do a checking on the record you updated.
If the number of rows is more than 2 billion, use ROWCOUNT_BIG.
Example
USE DB2008;
GO
UPDATE User
SET JobTitle = 'Manager'
WHERE UserID = 'u10021'
IF @@ROWCOUNT = 0
PRINT 'Warning: No rows were updated';
GO
Posted by Emil Chang at 7:35 PM 2 comments
SQL injection is an attack in which malicious code is inserted into strings that are later passed to an instance of SQL Server for parsing and execution. Any procedure that constructs SQL statements should be reviewed for injection vulnerabilities because SQL Server will execute all syntactically valid queries that it receives. Even parameterized data can be manipulated by a skilled and determined attacker. The primary form of SQL injection consists of direct insertion of code into user-input variables that are concatenated with SQL commands and executed. A less direct attack injects malicious code into strings that are destined for storage in a table or as metadata. When the stored strings are subsequently concatenated into a dynamic SQL command, the malicious code is executed.
Example
UserID = Request.form ("userid");
var sql = "select * from UserTable where ID= '" + UserID + "'";
| Input character | Meaning in Transact-SQL |
|---|---|
; | Query delimiter. |
' | Character data string delimiter. |
-- | Comment delimiter. |
/* ... */ | Comment delimiters. Text between /* and */ is not evaluated by the server. |
xp_ | Used at the start of the name of catalog-extended stored procedures, such as xp_cmdshell. |
Posted by Emil Chang at 5:33 AM 3 comments
Database SQL Syntax
- Different databases using different sql statement
DB2
select * from table fetch first 10 rows only
Informix
select first 10 * from table
Microsoft SQL Server and Access
select top 10 * from table
MySQL and PostgreSQL
select * from table limit 10
Oracle 8i
select * from (select * from table) where rownum <= 10
Posted by Emil Chang at 6:50 AM 0 comments

A linked server configuration allows Microsoft® SQL Server™ to execute commands against OLE DB data sources on different servers. Linked servers offer these advantages:
When setting up a linked server, register the connection information and data source information with SQL Server. After registration is success, that data source can always be referred to with a single logical name.
You can manage a linked server definition with stored procedures or through SQL Server Enterprise Manager:
With stored procedures:
- Create a linked server definition using sp_addlinkedserver. To view information about the linked servers defined in a given instance of SQL Server, use sp_linkedservers. For more information, see sp_addlinkedserver and sp_linkedservers.
- Delete a linked server definition using sp_dropserver. You can also use this stored procedure to remove a remote server. For more information, see sp_dropserver.
With SQL Server Enterprise Manager:
- Create a linked server definition using the SQL Server Enterprise Manager console tree and the Linked Servers node (under the Security folder). Define the name, provider properties, server options, and security options for the linked server. For more information about the various ways a linked server can be set up for different OLE DB data sources and the parameter values to be used, see sp_addlinkedserver.
- Edit a linked server definition by right-clicking the linked server and clicking Properties.
- Delete a linked server definition by right-clicking the linked server and clicking Delete.
Posted by Emil Chang at 7:18 AM 1 comments
SQL Server 2000
once the execution plan is generated for a Stored Procedure, it stays in the procedure cache. Lazy writer only keep looking and throwing out unused plans out of the cache "only when space is needed in cache".
Below are some documented and undocumented DBCC commands available in SQL Server 2000 to deal and find more information about SQL Server cache.
To Monitor the cahce:
DBCC SQLPERF (LRUSTATS)
DBCC CACHESTATS
DBCC MEMORYSTATUS
DBCC PROCCACHE
To clean the cache:
DBCC FLUSHPROCINDB
DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE
You can read more from SQL 2000 Topic under "Lazy Writer", 'Freeing and Writing Buffer Pages' at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ar_sa_8unn.asp
Posted by Emil Chang at 5:59 AM 1 comments
In Windows Server 2003, you able change the Address Windowing Extensions (AWE) API to provide access to physical memory in excess of the limits set on configured virtual memory. The specific amount of memory you can use depends on hardware configuration and operating system support.
Extra Note
Posted by Emil Chang at 6:43 AM 1 comments
Generates totals that appear as additional summary columns at the end of the result set. When used with BY, the COMPUTE clause generates control-breaks and subtotals in the result set.
USE Database;
GO
SELECT CustomerID, OrderDate, SubTotal, TotalDue
FROM Sales.SalesOrderHeader
WHERE ID = 1
ORDER BY OrderDate
COMPUTE SUM(SubTotal), SUM(TotalDue);
Posted by Emil Chang at 9:31 PM 0 comments