SQL Server: Grant user access permission to database

Categories: Database; Tagged with: ; @ October 17th, 2012 12:20

Grant user permission to login to the database:

USE YOUR_DB

CREATE USER ROA_NAME FOR LOGIN ROA_NAME

Add user to the group:

USER YOUR_DB

EXEC SP_ADDROLEMEMBER 'DB_DATAREADER', 'ROA_NAME'

“Members of the db_datareader fixed database role can run a SELECT statement against any table or view in the database.”

 

Links:
http://stackoverflow.com/questions/6688880/how-do-i-grant-read-access-for-a-user-to-a-database-in-sql-server

SQL Server: 用户登录失败Login failed, The user is not associated with a trusted SQL Server connection(Error: 18452)

Categories: Database; Tagged with: ; @ October 11th, 2012 18:52

有若干情形可能导致使用用户名/密码登录失败, 其中一类便是未开启登录模式:

image.

 

更详细的参考:

http://support.microsoft.com/kb/555332#method2

Generate SSIS log using dtexec 生成SSIS 日志

Categories: Database; Tagged with: ; @ October 9th, 2012 20:11

First we need to Config logging in SSIS package(GUI):

image

 

Two methods to generate the log:

1. Using SSIS ‘Connection’ to sotre the log;

Example:
dtexec /f DavidTest.dtsx  /l “DTS.LogProviderTextFile;log.txt”
(log.txt is a Connection in SSIS package).

2. Redirect console message into a file:

dtexec /f DavidTest.dtsx  /cons NMT >C:/ConsoleMsg.log

 

About the dtexec parameters:
http://msdn.microsoft.com/en-us/library/hh231187.aspx
SSIS Logging:
http://weblogs.sqlteam.com/jamesn/archive/2008/02/11/60502.aspx

How to add Simple Logging to an SSIS Package

SQL Server: Export data to CVS with headers using BCP

Categories: Database; Tagged with: ; @ September 25th, 2012 14:04

Use this BCP script to generate CSV file:


bcp "SELECT ''ID'', ''Username'' UNION ALL SELECT CAST(u.ID as varchar(10)),u.USERNAME from DavidTest.dbo.DavidUser u" queryout "c:\output.csv" -c -t"," -r"\n" -SServerName -T

If you want to run in SSMS, you can use:


USE MASTER
GO
DECLARE @query varchar(4000)

SET @query = '"SELECT...."';
EXEC xp_cmdshell @bcpOut
GO

for more info:
http://msdn.microsoft.com/en-us/library/aa174646(v=sql.80).aspx

SQL Server: New Linked Server from Excel

Categories: Database; Tagged with: ; @ September 13th, 2012 19:50

We can create a new linked server using Excel:

image

Select the Provider, Input the data source(excel path), and provider string, keep ‘Excel 8.0’.

Save, and you can see the server .

then you can query from the new server:

SELECT * FROM DAVIDEXCEL...Sheet1$;

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.