Showing posts with label format. Show all posts
Showing posts with label format. Show all posts

Wednesday, March 28, 2012

how to save result of sql query to .csv file "using command in sql query itself"

Hello there

I m new in sql..i want to know wether above said task is possible in sql?

if yes then what is exact format of sql query command..

Thanks

AVD

YOu can have a look in the BOL for OPENDATASOURCE, there should a sample for an output to a propetary format.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

How to save images to SQL Server?

Hi, All
I have a question?
I have scanned images (file format .tif) i need to store them in SQL Server.
And after all how fast is the search for those images (search on 200
thousands images and up)
Thank you,
Are you going to put some other fields for searching purpose e.g. file
name, date created, creator etc? Since they are image files, what kind
of search you want to put it on?
Mel
|||Hi,
Thank you for replay,
It will be one field "Ticket No", and i need to search by this field.
So it is possible, where i can get some more references? and SQL Server 2005
will be the answer
"MSLam" wrote:

> Are you going to put some other fields for searching purpose e.g. file
> name, date created, creator etc? Since they are image files, what kind
> of search you want to put it on?
> Mel
>

Monday, March 26, 2012

How to save images to SQL Server?

Hi, All
I have a question?
I have scanned images (file format .tif) i need to store them in SQL Server.
And after all how fast is the search for those images (search on 200
thousands images and up)
Thank you,Are you going to put some other fields for searching purpose e.g. file
name, date created, creator etc? Since they are image files, what kind
of search you want to put it on?
Mel|||Hi,
Thank you for replay,
It will be one field "Ticket No", and i need to search by this field.
So it is possible, where i can get some more references? and SQL Server 2005
will be the answer
"MSLam" wrote:

> Are you going to put some other fields for searching purpose e.g. file
> name, date created, creator etc? Since they are image files, what kind
> of search you want to put it on?
> Mel
>|||... still don't qutie get your question. I shall take it as follow:
You have a table that has at least two fields: Ticket No and Image.
The Ticket No will be using INT as the data type and the Image will be
using text/image data type.
You will be using Ticket No for users to search on OR
You will be using Image for users to search on
If ticket no will be the field users need to search on, it should not
take long to retrieve records (assuming the Ticket no here is data type
int). You can put a normal index on the field to speed up the search
(either clustered or non-clustered depending your situation).
If image will be the field users need to search on (based on text value
in the image file), you use FULL-TEXT index for this purpose.
Check BOL for more information about indexing.
Hope I got your question right.
Mel|||Thank you, Mel
I need perform search on "ticket No" field and if found ti retrive the image
.
Thanks again,
"MSLam" wrote:

> .... still don't qutie get your question. I shall take it as follow:
> You have a table that has at least two fields: Ticket No and Image.
> The Ticket No will be using INT as the data type and the Image will be
> using text/image data type.
> You will be using Ticket No for users to search on OR
> You will be using Image for users to search on
> If ticket no will be the field users need to search on, it should not
> take long to retrieve records (assuming the Ticket no here is data type
> int). You can put a normal index on the field to speed up the search
> (either clustered or non-clustered depending your situation).
> If image will be the field users need to search on (based on text value
> in the image file), you use FULL-TEXT index for this purpose.
> Check BOL for more information about indexing.
> Hope I got your question right.
> Mel
>

How to save images to SQL Server?

Hi, All
I have a question?
I have scanned images (file format .tif) i need to store them in SQL Server.
And after all how fast is the search for those images (search on 200
thousands images and up)
Thank you,Are you going to put some other fields for searching purpose e.g. file
name, date created, creator etc? Since they are image files, what kind
of search you want to put it on?
Mel|||Hi,
Thank you for replay,
It will be one field "Ticket No", and i need to search by this field.
So it is possible, where i can get some more references? and SQL Server 2005
will be the answer
"MSLam" wrote:
> Are you going to put some other fields for searching purpose e.g. file
> name, date created, creator etc? Since they are image files, what kind
> of search you want to put it on?
> Mel
>|||... still don't qutie get your question. I shall take it as follow:
You have a table that has at least two fields: Ticket No and Image.
The Ticket No will be using INT as the data type and the Image will be
using text/image data type.
You will be using Ticket No for users to search on OR
You will be using Image for users to search on
If ticket no will be the field users need to search on, it should not
take long to retrieve records (assuming the Ticket no here is data type
int). You can put a normal index on the field to speed up the search
(either clustered or non-clustered depending your situation).
If image will be the field users need to search on (based on text value
in the image file), you use FULL-TEXT index for this purpose.
Check BOL for more information about indexing.
Hope I got your question right.
Mel|||Thank you, Mel
I need perform search on "ticket No" field and if found ti retrive the image.
Thanks again,
"MSLam" wrote:
> .... still don't qutie get your question. I shall take it as follow:
> You have a table that has at least two fields: Ticket No and Image.
> The Ticket No will be using INT as the data type and the Image will be
> using text/image data type.
> You will be using Ticket No for users to search on OR
> You will be using Image for users to search on
> If ticket no will be the field users need to search on, it should not
> take long to retrieve records (assuming the Ticket no here is data type
> int). You can put a normal index on the field to speed up the search
> (either clustered or non-clustered depending your situation).
> If image will be the field users need to search on (based on text value
> in the image file), you use FULL-TEXT index for this purpose.
> Check BOL for more information about indexing.
> Hope I got your question right.
> Mel
>sql

Monday, March 19, 2012

How to return time & number format that has set in the regional setting using stored proce

How to return time & number format that has set in the regional setting using stored procedure.

Following is my sp for getting current date format from Sql Server.

if exists

(select*fromsysobjectswhereid =object_id(N'[HSP_GetDateFormat]')andOBJECTPROPERTY(id, N'IsProcedure') = 1)

drop procedure[HSP_GetDateFormat]

create procedure

HSP_GetDateFormat

(

@.strDateFormat nvarchar(64) out,

@.iErr

intout

)

as

begin

set nocount on

set@.strDateFormat = (selectdateformat frommaster..syslanguageswherelangid = (selectvaluefrommaster..sysconfigureswherecomment = 'default language'))

set@.iErr = @.@.Error

set nocount off

end

Now, I want to know what would I write if I want to get currenttime &numberformat from Sql Server.

Hi,

From your description, it seems that you want to get the current date time in stored procedure, right?

TSQL has provided several built-in functions which is used for datetime and datetiem calculating. You can get the current date and time by using GetDate() function, also, you can use such functions like DATEADD,DATEDIFF to calculate the date and time. See the following codes:

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE() ))

Besides, if you want to output the value, just create a datetime typed variable and set it as OUTPUT, and then create a parameter in .NET side, which shares the same type, set the direction as OUTPUT, then you can receive the datetime from your stored procedure. As for the number type, you can use INT,FLOAT,DOUBLE and etc in your stored procedure.

Thanks.

Monday, March 12, 2012

How to return large amount of data in the XML format

I have SQL 2000 and need to retrieve fairly large amout of data (~
50.000 characters) in XML format and then insert it into the field of
the text type.
As 'FOR XML' can't be used with either local variables, INSERT INTO or
SELECT INTO this makes "XML support" quite useless in many aspects.

Can anyone please help me in solving this.
Thanks a lot for your help and time.

PavelPavel (p.golobokov@.ausbulk.com.au) writes:
> I have SQL 2000 and need to retrieve fairly large amout of data (~
> 50.000 characters) in XML format and then insert it into the field of
> the text type.
> As 'FOR XML' can't be used with either local variables, INSERT INTO or
> SELECT INTO this makes "XML support" quite useless in many aspects.

You can try:

INSERT tbl (xmlcol)
SELECT * FROM OPENQUERY(LOCALSVR, 'SELECT ... FOR XML')

Where LOCALSVR has been created as

EXEC sp_addlinkedserver
@.server = 'LOCALVR',
@.srvproduct = '',
@.provider = 'MSDASQL',
@.datasrc = 'LocalServer'

That is, you use the deprecated OLE DB over ODBC provider. This works
so far that you get XML back. However, you may find that the text
has been broken into many rows. (If you would use SQLOLEDB, the real
SQL Server provider, you get a blob back.)

If this does not work out, you will have a find a client to pick up the
XML and send it back.

In SQL 2005, the XML support is considerably enhanced, and you should
be able to do this without weird workarounds.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

How to return date formated like (yyyy/mm/dd)

Hi everybody

Exemple of query
SELECT DT_FIELD FROM TABLE_NAME

DT_FIELD
-------
2001-12-20 00:00:00 --This format is not right

The query must return like that
DT_FIELD
-------
2001-12-20 --This is the good format

I try this function datePart, Convert and cast but is not right

ThankOriginally posted by ericjean
Hi everybody

Exemple of query
SELECT DT_FIELD FROM TABLE_NAME

DT_FIELD
-------
2001-12-20 00:00:00 --This format is not right

The query must return like that
DT_FIELD
-------
2001-12-20 --This is the good format

I try this function datePart, Convert and cast but is not right

Thank|||Thank everybody

I can do like this
SELECT convert(varchar(10),DT_FIELD,103) FROM TABLENAME|||FYI for others having the same issue - the convert function has a style parameter which allows for various datetime formats.

Friday, February 24, 2012

How to retrieve DATETIME format?

Hello, everyone:

My table has a column that is DATETIME data type. The original format likes "1/21/2004". I want to check data lengh. However when I read the data by SELECT, SQL Server change the format to "Jan.-21-2004" automatically. Does any one has an idea to keep original datetime format? Thanks.

ZYTthere is no original format

you may use a format for input that sql server understands, but internally, the date is stored as an integer (number of days since the base date)

check out BOL (Books Online) for details

if you want to see a specific format when you SELECT a datatime value, then use the CONVERT function