手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:sqlserver

工作笔记

一个句子的迁移,一个粗心:
原mysql代码是:select date_format(from_unixtime(xxx),'%Y-%M') as xxxxx from table group by xxxxx

sql server转换后:
select (select dateadd(ss,xxx,'1970-01-01 08:00:00')) as xxxxx from table group by xxxxx
因为sql server不支持将as 后的内容做聚集,只能:
select dateadd(ss,xxx,'1970-01-01 08:00:00') as xxxxx from table group by (select dateadd(ss,xxx,'1970-01-01 08:00:00'))
但又报错,说是group by 不能使用子查询。

仔细想了想,(select dateadd(ss,xxx,'1970-01-01 08:00:00')) as xxxxx,这个select用来干嘛 ?如果是在查询分析器里,当然是要用select,因为要输出嘛,但是在sql语句中。。。
不需要啊。

记录一下。

Tags: sqlserver, mysql, convert

php freetds 处理sqlserver大字段的问题

freetds连接sqlserver是没问题,在连接的时候dsn用的是dblib,而不是mssql。
连接和普通的查询都没有问题,但一旦涉及到大字段,你就会发现问题多多了。比如你的字段类型是nvarchar(max),你在处理的时候你会发现,返回结果都是空。
我晶啊。看来php连接sqlserver还是用windows自己的方案吧:sqlsrv这个组件,但它只能在windows下面使用。

太纠结了

Tags: freetds, sqlserver, 大字段

Persist Security InFso=true 是什么意思

Conn2.Open "Provider=SQLOLEDB.1;Persist Security InFso=true;Data Source=192.168.1.2;Initial Catalog=xxxxx;User ID=sa;Password=123456;"

一些参考信息:
Integrated   Security默认值是False,此时需要提供Uid和Pwd,即将以Sql   Server   用户身份登陆数据库;如果设置为True,Yes   或   SSPI,这不能出现Uid和Pwd,将以Windows用户省份登陆数据库。强烈推荐用后一种形式,安全性更高。

参见
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp
--------
http://expert.csdn.net/Expert/topic/2930/2930660.xml?temp=.423382

Persist   Security   Info   布尔类型,为True时,表明采用集成安全机制;若为False,则表明不采用集成安全机制。

更多资料还是看:http://connectionstrings.com/,还是这个网站好玩。

Tags: sqlserver

Microsoft SQL Server Functions (PDO_SQLSRV)

Introduction

PDO_SQLSRV is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MS SQL Server (starting with SQL Server 2005) and SQL Azure databases.

Installation

The PDO_SQLSRV extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file. The PDO_SQLSRV download comes with several driver files. Which driver file you use will depend on 3 factors: the PHP version you are using, whether you are using thread-safe or non-thread-safe PHP, and whether your PHP installation was compiled with the VC6 or VC9 compiler. For example, if you are running PHP 5.3, you are using non-thread-safe PHP, and your PHP installation was compiled with the VC9 compiler, you should use the php_pdo_sqlsrv_53_nts_vc9.dll file. (You should use a non-thread-safe version compiled with the VC9 compiler if you are using IIS as your web server). If you are running PHP 5.2, you are using thread-safe PHP, and your PHP installation was compiled with the VC6 compiler, you should use the php_pdo_sqlsrv_52_ts_vc6.dll file.

For more information about system requirements, see » SQLSRV System Requirements.

The PDO_SQLSRV extension is only compatible with PHP running on Windows. For Linux, see ODBC and » Microsoft's SQL Server ODBC Driver for Linux.

System Requirements (Microsoft Drivers for PHP for SQL Server)

 

SQL Server 2008 R2

To access data in a SQL Server 2005 or later database using the Microsoft Drivers for PHP for SQL Server, you must have the following components installed on your computer:

  • Supported operating systems for version 3.0 of the driver include:

    • Windows Server 2008 R2 SP1

      Windows Vista SP2

      Windows Server 2008 SP2

      Windows 7 SP1

  • Supported operating systems for version 2.0 of the driver include:

    • Supported operating systems for version 2.0 of the driver include:

    • Windows Server 2003 Service Pack 1

    • Windows XP Service Pack 3

    • Windows Vista Service Pack 1 or later

    • Windows Server 2008

    • Windows Server 2008 R2

    • Windows 7

  • PHP 5. For information about how to download and install the latest stable binaries, visit http://php.net.

    Microsoft Drivers for PHP for SQL Server, version 3.0 requires PHP 5.3.0 or later. If possible, use PHP 5.3.6, or later. The version 2.0 driver works with PHP 5.2.4 or later. If possible, use PHP 5.2.13, or later.

  • A version of the driver file must be in your PHP extension directory. See Driver Versions later in this topic for information about the different driver files. See Loading the Microsoft Drivers for PHP for SQL Server for information on configuring the driver for the PHP runtime.

    (See The Data Center for the Microsoft Drivers for PHP for SQL Server for information on where to download the Microsoft Drivers for PHP for SQL Server.)

  • A Web server. Your Web server must be configured to run PHP. For information about hosting PHP applications with Internet Information Services (IIS) 6.0, see Using FastCGI to Host PHP Applications on IIS 6.0. For information about hosting PHP applications with IIS 7.0, see Using FastCGI to Host PHP Applications on IIS 7.0.

    The Microsoft Drivers for PHP for SQL Server has been tested using IIS 6 and IIS 7 with FastCGI.

  • The x86 version of SQL Server Native Client is required on the computer where PHP is running. If you are using a 64-bit operating system, the x86 version of SQL Server Native Client will be installed with the x64 version of SQL Server Native Client (do not install the x86 version of SQL Server Native Client on an x64 operating system).

    If you are using the SQLSRV driver, sqlsrv_client_info will return information about which version of SQL Server Native Client is being used by the Microsoft Drivers for PHP for SQL Server. If you are using the PDO_SQLSRV driver, you can use PDO::getAttribute to discover the version.

This section lists the drivers that are installed for version 2.0 and version 3.0 of the Microsoft Drivers for PHP for SQL Server. PHP version 5.2 is not supported in version 3.0 of the Microsoft Drivers for PHP for SQL Server.

Follow the installation instructions in Loading the Driver to configure the driver for use with the PHP runtime.

Microsoft Drivers 2.0 for PHP for SQL Server installs several versions of the driver:

 

Driver file

PHP version

Thread safe?

Use with PHP .dll

php_sqlsrv_53_nts_vc6.dll

php_pdo_sqlsrv_53_nts_vc6.dll

5.3

no

php5.dll

php_sqlsrv_53_nts_vc9.dll

php_pdo_sqlsrv_53_nts_vc9.dll

5.3

no

php5.dll

php_sqlsrv_53_ts_vc6.dll

php_pdo_sqlsrv_53_ts_vc6.dll

5.3

yes

php5ts.dll

php_sqlsrv_53_ts_vc9.dll

php_pdo_sqlsrv_53_ts_vc9.dll

5.3

yes

php5ts.dll

php_sqlsrv_52_nts_vc6.dll

php_pdo_sqlsrv_52_nts_vc6.dll

5.2

no

php5.dll

php_sqlsrv_52_ts_vc6.dll

php_pdo_sqlsrv_52_ts_vc6.dll

5.2

yes

php5ts.dll

If the name of the driver file contains "vc9", it should be used with a PHP version compiled with Visual C++ 9.0.

Microsoft Drivers 3.0 for PHP for SQL Server installs several versions of the driver:

 

Driver file

PHP version

Thread safe?

Use with PHP .dll

php_sqlsrv_53_nts.dll

php_pdo_sqlsrv_53_nts.dll

5.3

no

php5.dll

php_sqlsrv_53_ts.dll

php_pdo_sqlsrv_53_ts.dll

5.3

yes

php5ts.dll

Tags: sqlserver, microsoft, pdo

备份:sqlserver to mysql

从sqlserver转到mysql上相对还是比较方便的,外面的工具层出不穷,比如dbconverter之类的,可惜它是商业版,而且,15M左右,还TNND没有破解版。
问了一下google和百度,最终度娘没有帮我解决,而且谷哥告诉我答案了:http://www.cnblogs.com/andrew-blog/archive/2011/12/03/SQL_mss2sql.html
然后下载到本地。做个备份,以后可以直接用
下载:mss2sql.rar
只有1.3M哦,非常好用,昨天帮一个朋友转数据的时候,只花了大约半小时左右转换了将近1G左右的数据。

由于用法简单就不多做介绍了,sqlserver的登录可以直接选系统登录,而不需要输入密码,你懂的。甚至可以支持远程导入,黑黑。。。当然这受限于网络带宽的传输了。
如果还不会,就看我上面的URL吧,里面有图文教学,不过我相信,即使没有教学,也是下一步下一步就会搞的。

Tags: sqlserver, mysql, convert

Records:812