Thanks for your response. But I am not getting your idea
Can you try with this data
declare @tbl1 table
(id int,
pname varchar(100)
)
declare @tbl2 table
(id1 int,
id int,
fname varchar(100)
)
insert into @tbl1 (id, pname)
select 1, 'aa'
union all
select 2, 'bb'
union all
select 3, 'cc'...
Here is a data
declare @tbl1 table
(id int,
pname varchar(100)
)
declare @tbl2 table
(id1 int,
id int,
fname varchar(100)
)
insert into @tbl1 (id, pname)
select 1, 'aa'
union all
select 2, 'bb'
union all
select 3, 'cc'
insert into @tbl2 (id1, id, fname)
select 1, 1, 'dd'
union all
select...
I have tables say tbl1, tbl2, tbl3
I am joing this table to get back some recordsets
select a.col1
b.col2
c.col3
from tbl1 a inner join tbl2 b
on a.col1 = b.col2
inner join tbl3 c
on b.col1 = c.col2
the resultset will teturn
col1 col2 col3
1370 1446 aa...
I should keep all them though.
The problem is with the NULL, if one field is Null,
I think I can't equate the Null field
I used 'SET ANSI_NULLS OFF' in my code, it is not helping out
any suggestion how to equate two null fields?
Thanks
...tmp2 INNER JOIN @ReportTable tmp
ON tmp2.ID = tmp.ID
AND tmp2.DOCID = tmp.DOCID
AND tmp2.VNum = tmp.VNum
AND tmp2.[Date] = tmp.[Date]
AND tmp2.IDEN = tmp.IDEN
AND tmp2.IDENDate = tmp.IDENDate
SELECT * FROM @tmpTable4
GO
SET ANSI_NULLS ON
thanks,
...tmp2 INNER JOIN @ReportTable tmp
ON tmp2.ID = tmp.ID
AND tmp2.DOCID = tmp.DOCID
AND tmp2.VNum = tmp.VNum
AND tmp2.[Date] = tmp.[Date]
AND tmp2.IDEN = tmp.IDEN
AND tmp2.IDENDate = tmp.IDENDate
SELECT * FROM @tmpTable4
GO
SET ANSI_NULLS ON
thanks,
I wrote a query which can be run on different servers
I want to pass the server name and database name as a parameter to my query.
how can I do that
can I do
select * from @servername.@databasename.dbo.tbl
Thanks
you mean
update svr1.db1.dbo.tmp
set col1 = 'a'?
I tried this and generated this error
[OLE/DB provider returned message: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB'...
...tmp.col1 = 1 then tmp.col1 + 1
else tmp.col1 + 2
end
from OPENROWSET('SQLOLEDB','svr1';'uid';'pwd','select * from db1.dbo.tbl') tmp
but it is erroring
the error is
Msg 208, Level 16, State 1, Line 1
Invalid object name 'tmp'.
a linkedserver is all...
I have created a linked list, but it still fails to update
here is the error
[OLE/DB provider returned message: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB'...
I have a table called tbl on server svr1, database db1, owner is dbo
I want to update it from server svr2, database db2
I wrote a query
update svr1.db1.dbo.tbl
set col1 = case when col1 = 1 then 1.0
else 2.0
end
where col2 = 'aa'
but it is complaining
what should...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.