Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql server 2005

Author  Topic 

SudhaKrishnan
Starting Member

6 Posts

Posted - 2012-02-13 : 01:52:04
Hi,

I need to insert image in db and also need to view without front-end using sql server 2005. When im using sql server query, its giving error like "Incorrect syntax near the keyword 'Bulk'".

Query :
CREATE TABLE myTable(Document varbinary(8000))
INSERT INTO myTable(Document)
SELECT * FROM
OPENROWSET(BULK N'C:\test.bmp', SINGLE_BLOB)

If anyone knows let me know how to insert and view the image from db.

Thanks,
Sudha K

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-13 : 10:29:52
it should work fine
can you check if table is getting created first?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SudhaKrishnan
Starting Member

6 Posts

Posted - 2012-02-15 : 08:20:20
Yes, table was created when i using varbinary(8000).

But, when i using more than 8000 (or) MAX for varbinaray, table is not creating. Its throwing error.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-15 : 09:21:25
quote:
Originally posted by SudhaKrishnan

Yes, table was created when i using varbinary(8000).

But, when i using more than 8000 (or) MAX for varbinaray, table is not creating. Its throwing error.


whats the version of sql server you're working on?

what does below return?

SELECT @@VERSION

EXEC sp_dbcmptlevel 'your db name'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SudhaKrishnan
Starting Member

6 Posts

Posted - 2012-02-16 : 06:12:54
Hi,

Its showing sql server 2000 Service package 2. In visibly its showing sql server 2005...
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-02-16 : 06:25:02
What is the exact output of those two commands?

What do you mean by 'In visibly its showing sql server 2005'? Using 2005's management studio as a client interface?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

SudhaKrishnan
Starting Member

6 Posts

Posted - 2012-02-16 : 07:15:15
Yes, Im using SQL Server Management Studio. Its under SQL Server 2005 Menu in All Programs.

Exact output of those 2 Command is,

Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-02-16 : 08:23:08
You're connecting to a SQL 2000 server. The version of the client tools does not affect what features are allowed. It's a SQL 2000 server, so no VARCHAR(max), no OPENROWSET... BULK.

You're going to have to find another way, a way that works on SQL 2000 (and unless the image is under 8000 bytes, you'll need to change the data type to image)

--
Gail Shaw
SQL Server MVP
Go to Top of Page

SudhaKrishnan
Starting Member

6 Posts

Posted - 2012-02-17 : 05:00:40
Ok thank you... when im using image type for image in sql server 2000 is working fine.

How to connect the local server of sql server 2005??
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-02-17 : 06:08:02
Specify the server name and if necessary instance name for the SQL 2005 server when you connect. You'll connect to whatever it is that you specify in the connection dialog.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

SudhaKrishnan
Starting Member

6 Posts

Posted - 2012-02-17 : 08:14:08
Hi,

When i working with Local SQL Server 2005 its working fine. Thank you..

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-17 : 12:59:40
quote:
Originally posted by SudhaKrishnan

Hi,

When i working with Local SQL Server 2005 its working fine. Thank you..




OPENROWSET BULK is available only from SQL 2005 onwards that was why it didnt work at first

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -