Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: PHP/MS SQL ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 10950 of 11409
Post > Topic >>

Re: PHP/MS SQL - automatic formatting: varchar, datetime

by Erland Sommarskog <esquel@[EMAIL PROTECTED] > Apr 10, 2008 at 09:09 PM

W?adys?aw Bodzek (wbodzek_nospam@[EMAIL PROTECTED]
) writes:
> I want to change 2 default behaviors of ms-sql server within a
connection.
> 
> 1. All varchar (etc.) fields should be returned as UTF-8.
>     I know about field attribute collation and convert function,
>     but I want simple query like:
>        SELECT * FROM table;
>     to return all varchars as UTF-8, no matter how the fields were
>     defined and which collation.
> 
>     In MySQL I execute: "SET NAMES 'utf-8';" after connecting to server
>     In PgSQL I use native function: pg_set_client_encoding()

There is no setting for this in SQL Server. This is something you need to
deal with client side.
 
> 2. Default datetime format is sth like this: "Apr 20 2008 12:01PM"
>     I just want all datetimes fields were returned as:
>        "2008-04-20 12:01:02"
>     I can do that with function convert() (style=20) but I want
>     (as in question above) a simple query like:
>        SELECT * FROM table;
>     to return date and time formatted as described above.
> 
>     In MySQL and PgSQL the format "2008-04-20 12:01:02" is the default
>     one.
 
SQL Server returns datetime values as binary values, and it is up to
the client to format it. You will have to ask in a PHP forum how to do
that.


-- 
Erland Sommarskog, SQL Server MVP, esquel@[EMAIL PROTECTED]
 Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
 




 4 Posts in Topic:
PHP/MS SQL - automatic formatting: varchar, datetime
=?ISO-8859-2?Q?W=B3adys=B  2008-04-10 06:31:10 
Re: PHP/MS SQL - automatic formatting: varchar, datetime
Tom van Stiphout <no.s  2008-04-10 07:03:40 
Re: PHP/MS SQL - automatic formatting: varchar, datetime
Erland Sommarskog <esq  2008-04-10 21:09:08 
Re: PHP/MS SQL - automatic formatting: varchar, datetime
warrenkimberlys@[EMAIL PR  2008-04-11 17:41:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 15:38:36 CDT 2008.