Showing posts with label message. Show all posts
Showing posts with label message. Show all posts

Friday, March 30, 2012

OPENQUERY vs 4-part-tablenames with linked server

This is a multi-part message in MIME format.
--=_NextPart_000_000A_01C45DBF.3F502450
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
what is the difference between
a) select * from server.database.owner.table where [id] =3D 15
and
b) select * from openquery(server, 'select * from database.owner.table = where [id] =3D 15')
I have the effect that b) gives the correct result while a) has zero = hits.
Can anybody help?
Jochen
--=_NextPart_000_000A_01C45DBF.3F502450
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Hi,

what is the difference between =

a) select * from = server.database.owner.table where [id] =3D 15

and

b) select * from openquery(server, = 'select * from database.owner.table where [id] =3D 15')

I have the effect that b) gives the = correct result while a) has zero hits.

Can anybody help?

Jochen

--=_NextPart_000_000A_01C45DBF.3F502450--This is a multi-part message in MIME format.
--=_NextPart_000_0261_01C45DD6.DCF0CE50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Jochen
That's strange. I hace just tested it on my box and it works fine
As far as I know when we use OPENQUERY SQL Server opens an addition =connection to retrieve the data ( I am not sure for 100 percent)
"Jochen Br=FCggemann" <brueggemann@.ifap.de> wrote in message =news:udF3I4aXEHA.736@.TK2MSFTNGP10.phx.gbl...
Hi,
what is the difference between
a) select * from server.database.owner.table where [id] =3D 15
and
b) select * from openquery(server, 'select * from database.owner.table =where [id] =3D 15')
I have the effect that b) gives the correct result while a) has zero =hits.
Can anybody help?
Jochen
--=_NextPart_000_0261_01C45DD6.DCF0CE50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Jochen
That's strange. I hace just tested it on my box and =it works fine
As far as I know when we use OPENQUERY SQL Server =opens an addition connection to retrieve the data ( I am not sure for 100 percent)
"Jochen Br=FCggemann" wrote =in message news:udF3I4aXEHA.736@.T=K2MSFTNGP10.phx.gbl...
Hi,

what is the difference between =
a) select * from =server.database.owner.table where [id] =3D 15

and

b) select * from openquery(server, ='select * from database.owner.table where [id] =3D 15')

I have the effect that b) gives the =correct result while a) has zero hits.

Can anybody help?

Jochen


--=_NextPart_000_0261_01C45DD6.DCF0CE50--|||This is a multi-part message in MIME format.
--=_NextPart_000_0043_01C45DD2.46A106D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Here are some additional information:
SQL 2000 SP3 - Build 8.00.818
The database is merge replicated, but the effect is still there when I =delete all replicational stuff.
Some more effects:
[id]-clumn has data from von 1 - 8000. With
select * from server.database.owner.table where [id] < 6000
the result table ist still empty. With
select * from server.database.owner.table where [id] < 6001
all rows are given back with [id] < 60001. Further it is strange that =the server answers with correct results when I start the query on =itsself (as whith OPENQUERY).
Jochen
"Uri Dimant" <urid@.iscar.co.il> schrieb im Newsbeitrag =news:Os4al2bXEHA.2520@.TK2MSFTNGP12.phx.gbl...
Jochen
That's strange. I hace just tested it on my box and it works fine
As far as I know when we use OPENQUERY SQL Server opens an addition =connection to retrieve the data ( I am not sure for 100 percent)
"Jochen Br=FCggemann" <brueggemann@.ifap.de> wrote in message =news:udF3I4aXEHA.736@.TK2MSFTNGP10.phx.gbl...
Hi,
what is the difference between
a) select * from server.database.owner.table where [id] =3D 15
and
b) select * from openquery(server, 'select * from =database.owner.table where [id] =3D 15')
I have the effect that b) gives the correct result while a) has zero =hits.
Can anybody help?
Jochen
--=_NextPart_000_0043_01C45DD2.46A106D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Here are some additional =information:
SQL 2000 SP3 - Build 8.00.818
The database is merge replicated, but =the effect is still there when I delete all replicational stuff.
Some more effects:
[id]-clumn has data from von 1 - 8000. Withselect * from server.database.owner.table where [id] < 6000the result =table ist still empty. Withselect * from server.database.owner.table where =[id] < 6001all rows are given back with [id] < 60001. Further it is =strange that the server answers with correct results when I start the query on =itsself (as whith OPENQUERY).
Jochen
"Uri Dimant" schrieb im =Newsbeitrag news:Os4al2bXEHA.2520=@.TK2MSFTNGP12.phx.gbl...
Jochen
That's strange. I hace just tested it on my box =and it works fine
As far as I know when we use OPENQUERY SQL Server =opens an addition connection to retrieve the data ( I am not sure for 100 percent)
"Jochen Br=FCggemann" =wrote in message news:udF3I4aXEHA.736@.T=K2MSFTNGP10.phx.gbl...
Hi,

what is the difference between =
a) select * from =server.database.owner.table where [id] =3D 15

and

b) select * from openquery(server, ='select * from database.owner.table where [id] =3D 15')

I have the effect that b) gives the =correct result while a) has zero hits.

Can anybody help?

Jochen


--=_NextPart_000_0043_01C45DD2.46A106D0--|||OPENQUERY allow you to control exactly what is passed to the other DBMS. I suggest you use showplan
to see what is submitted to the other DBMS in both cases...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Jochen Brüggemann" <brueggemann@.ifap.de> wrote in message
news:udF3I4aXEHA.736@.TK2MSFTNGP10.phx.gbl...
Hi,
what is the difference between
a) select * from server.database.owner.table where [id] = 15
and
b) select * from openquery(server, 'select * from database.owner.table where [id] = 15')
I have the effect that b) gives the correct result while a) has zero hits.
Can anybody help?
Jochen|||This is a multi-part message in MIME format.
--=_NextPart_000_0050_01C45DAD.F4088160
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
In this case OPENQUERY should return the same result as the straight =query...
Do as Tibor says, and check the query plan for both to see if you can =learn anything from that...Also check/play with the collation order =options on the linked server(although that should not matter with an =integer comparison.)
-- Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Jochen Br=FCggemann" <brueggemann@.ifap.de> wrote in message =news:udF3I4aXEHA.736@.TK2MSFTNGP10.phx.gbl...
Hi,
what is the difference between
a) select * from server.database.owner.table where [id] =3D 15
and
b) select * from openquery(server, 'select * from database.owner.table =where [id] =3D 15')
I have the effect that b) gives the correct result while a) has zero =hits.
Can anybody help?
Jochen
--=_NextPart_000_0050_01C45DAD.F4088160
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

In this case OPENQUERY should return =the same result as the straight query...
Do as Tibor says, and check the query =plan for both to see if you can learn anything from that...Also check/play with the =collation order options on the linked server(although that should not matter with =an integer comparison.)
-- Wayne Snyder, MCDBA, SQL Server MVPMariner, =Charlotte, NChttp://www.mariner-usa.com">www.mariner-usa.com(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it'scommunity of SQL Server professionals.http://www.sqlpass.org">www.sqlpass.org
"Jochen Br=FCggemann" wrote =in message news:udF3I4aXEHA.736@.T=K2MSFTNGP10.phx.gbl...
Hi,

what is the difference between =
a) select * from =server.database.owner.table where [id] =3D 15

and

b) select * from openquery(server, ='select * from database.owner.table where [id] =3D 15')

I have the effect that b) gives the =correct result while a) has zero hits.

Can anybody help?

Jochen


--=_NextPart_000_0050_01C45DAD.F4088160--

OpenQuery Error?

Hi All,

I have an Openquery insert within a trigger. When i go to check the syntax it errors with the following message...

Error 403. Invalid Error for Data Type. Operator equals add, type equals varchar.

Below is my Openquery statement

SET @.TSQL2 = 'INSERT INTO ' +
'OPENQUERY([TRILOGY-TSG],''Select DET_NUMBERA, ADR_TYPEA, ADR_LINE_1A, ADR_LINE_2A, ADR_LINE_3A, ADR_LINE_4A, ADR_PST_CODEA, ADR_AREA_CODA, ADR_PHONEA, ADR_CNT_SURA, ' +
'ADR_CNT_NAMEA, ADR_CNT_RELA, FILLER_01A, ADR_STATEA, ADR_MOBILEA, FILLER_02A, SRGTE_KEY_1 FROM CHRISCS.EMADR'') ' +
'VALUES(''' + @.EMPLOYEE_NO + ''', ''E'', ''' + @.ADDRESS1 + ''', ''' + @.ADDRESS2 + ''', ''' + @.SUBURB + ''', ''' + @.COUNTRY + ''', ''' + @.POSTCODE + ''', ' +
'''' + @.AREACODE + ''', ''' + @.WORK1 + ''', ''' + @.ECD_SURNAME + ''', ''' + @.ECD_FIRSTNAME + ''', ''' + @.ECD_RELATIONSHIP + ''', '''', ''' + @.STATE + ''', ''' + @.MOBILE + ''', ' +
''' IT :21105101017 '', ''' + @.KEYE + ''')'

All variables are varchar except for @.KEYE which is Varbinary and this is the one that is causing the error on, because if I take it out the syntax is correct.

Any ideas why this occurs and how do I add a varbinary variable to the statement??

Regards
Anthonyyou are trying to concat string with varbin - this will not work. you have to convert to varchar before...|||Originally posted by msieben
you are trying to concat string with varbin - this will not work. you have to convert to varchar before...

How do I do this?? Can you show me an example.|||Originally posted by aljubicic
:
Below is my Openquery statement

SET @.TSQL2 = 'INSERT INTO ' +
'OPENQUERY([TRILOGY-TSG],''Select DET_NUMBERA, ADR_TYPEA, ADR_LINE_1A, ADR_LINE_2A, ADR_LINE_3A, ADR_LINE_4A, ADR_PST_CODEA, ADR_AREA_CODA, ADR_PHONEA, ADR_CNT_SURA, ' +
'ADR_CNT_NAMEA, ADR_CNT_RELA, FILLER_01A, ADR_STATEA, ADR_MOBILEA, FILLER_02A, SRGTE_KEY_1 FROM CHRISCS.EMADR'') ' +
'VALUES(''' + @.EMPLOYEE_NO + ''', ''E'', ''' + @.ADDRESS1 + ''', ''' + @.ADDRESS2 + ''', ''' + @.SUBURB + ''', ''' + @.COUNTRY + ''', ''' + @.POSTCODE + ''', ' +
'''' + @.AREACODE + ''', ''' + @.WORK1 + ''', ''' + @.ECD_SURNAME + ''', ''' + @.ECD_FIRSTNAME + ''', ''' + @.ECD_RELATIONSHIP + ''', '''', ''' + @.STATE + ''', ''' + @.MOBILE + ''', ' +
''' IT :21105101017 '', ''' + @.KEYE + ''')'
:


the code you posted will build the insert statement togeter and put it into @.TSQL2 as a varchar. so everything you put toghether needs to be varchar or to be converted to (either by the sql-server or by using "convert(". i don't know what you really want to do - but look alt sp_executesql in BOL. you can store your statement into varchar and use parameters, which will be replaced at runtime. so you don't have to push your values list into the varchar at all.

Friday, March 9, 2012

OnVariableChangedEvent Log Message

I have posted a very simple request to have the message in the SSIS log from an OnVariableValueChanged Event to include the vale the variable has been set to.

If you like the idea of this enhancement please go and vote and validate it here

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=238803

Phil,

What does it have in there currently?

-Jamie

|||Just the name of the variable that changed

Saturday, February 25, 2012

Only functions and extended stored procedures can be executed from within a function

Hi everybody,

When i try to excute a function i got the following error message:
" Only functions and extended stored procedures can be executed from within a function."

I wrote the following stored procedure wich update the sequence id :
---------------------
CREATE PROCEDURE dbo.pr_get_id_sequence
(@.p_nom_sequence varchar(100),
@.p_nom_table varchar(100),
@.p_id_sequence numeric OUTPUT ) AS

-- return an error if sequence does not exist
-- so we will know if someone truncates the table
DECLARE @.v_id_sequence numeric

SET @.v_id_sequence = -1

UPDATE GST_SEQUENCE
SET @.v_id_sequence = ID_SEQUENCE = ID_SEQUENCE + 1
WHERE NOM_SEQUENCE = @.p_nom_sequence
AND NOM_TABLE = @.p_nom_table

SET @.p_id_sequence = @.v_id_sequence
RETURN @.p_id_sequence

Then, i wrote the following function which return the last value of sequence id:
--------------------
CREATE FUNCTION dbo.fu_get_id_sequence
(@.p_nom_sequence varchar(100),
@.p_nom_table varchar(100)
) returns int AS

BEGIN
DECLARE @.v_id_sequence numeric

Execute dbo.pr_get_id_sequence @.p_nom_sequence, @.p_nom_table, @.v_id_sequence

RETURN @.v_id_sequence

END

And, when i try to call the function, i got the error message:
-------------------
select dbo.fu_get_id_sequence ('SEQ', 'TABLE')

By the way i'm using SQL Server 2005. Also, I tried to create the function by incliding the UPDATE statement but it didn't work.

Can anyone help me ?
Thank you

PaulThe error messages clearly point to the source of error: you cannot call stored procedures, as well as perform updates, deletes and inserts in T-SQL functions. That's why you cannot execute your function. You'll have to create stored procedure instead of function to be able to call another stored procedure. Also, all output parameters should be explicitly marked as output when you call a stored procedure:

Execute dbo.pr_get_id_sequence @.p_nom_sequence, @.p_nom_table, @.v_id_sequence output

Only Administrator May Connect

What would cause a SQL Server 2000 Clustered server to
output the error message listed below. This is a Windows
2000 Advanced Server. The error was pulled out of the SQL
Server Errorlog.
Error Message:
Login failed for user 'DALLAS\BLKSDRRT'. Only
administrators may connect at this time.
Thank You,
Dan
You may have the database access restricted to members of db_owner, dbcreator or sysadmins. Administrators can set this using either SQL Enterprise Manager or the sp_dboptions '[database name]','dbo use only' TSQL command. If you run the previous comman
d (and you are in the sysadmin role or db_owner role) it will tell you if it is "ON" or "OFF".
|||This can also occur if SQL Server it self has been set to single user mode.
Rand
This posting is provided "as is" with no warranties and confers no rights.

Monday, February 20, 2012

Online book links not working

I am trying to use sql server books online to get sql
help. However some links are not working.
Error message states:
Object does'nt support this method or property
Reinstalled the books. But still not working.Can you provide some more details about which links are not working? When
do you get the error message exactly? Can you display any topics at all?
Gail Erickson [MSFT]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"sselva" <anonymous@.discussions.microsoft.com> wrote in message
news:026201c394e6$aee04c70$a401280a@.phx.gbl...
> I am trying to use sql server books online to get sql
> help. However some links are not working.
> Error message states:
> Object does'nt support this method or property
> Reinstalled the books. But still not working.
>