Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Friday, March 23, 2012

of any concern??

This is a reoccurring error in one of our Domain Controllers event logs…

Event Type: Error
Event Source: KDC
Event Category: None
Event ID: 11
Date: 7/24/2007
Time: 6:23:05 AM
User: N/A
Computer: DC2
Description:
There are multiple accounts with name MSSQLSvc/dbsrvr-02.olntv.local:1433 of type DS_SERVICE_PRINCIPAL_NAME.

the Server dbsrvr-02 (sql server 2000 standard edition sp3a) has a default instance and it looksl ike 2 named instances installed that we are not using. Ive searched this error and cannot find a thing.. should this concern me? anyone ?Fyi http://www.eventid.net/display.asp?eventid=11&eventno=569&source=KDC&phase=1 and also if you areusing active directory, i t means there are duplicate entries in Active Directory for this service principal name. A directory administrator can use ldp.exe to search for the duplicates and either ldp.exe again or adsiedit.msc to delete the duplicates.

Odd Unicode problem

I use Server2000 and ADO connection and Unicode.
I have fields type of nvarchar.
And when I do the search ADO creates the SQL statement like this:
exec sp_executesql N'SELECT * FROM dbo.AB_Entities ab_e (NOLOCK) INNER JOIN
dbo.AB_EntityTreeNodeLink ab_etl (NOLOCK) ON
ab_e.EntityId=ab_etl.ChildEntityId WHERE ( ab_e.EntityCluster = @.P1) AND (
ab_e.EntityTitle = @.P2 AND ab_e.EntityType = @.P3) ', N'@.P1 int,@.P2
nvarchar(120),@.P3 smallint', 0, N'?', 7
(Caught from Profiler)
And this result nothing.
but when I delete the N from the second parameter:
..., N'@.P1 int,@.P2 nvarchar(120),@.P3 smallint', 0, '?', 7 <-- no N
before the Unicode variable, it works (work - means result the correct
records)!
and to make it more odd
..., N'@.P1 int,@.P2 nvarchar(120),@.P3 smallint', 0, N'John', 7 -- with N
works too.
I have tested those statements on S2k Query Analyzer and S2k5 SQL Server
Management Studio Express and there are same results.
Have anyone any idea what is wrong?
Regards,
Tomasz RutkowskiHi Tom
My guess is that your data is not what you expect
If you update the data
BEGIN TRANSACTION
UPDATE dbo.AB_EntityTreeNodeLink
SET EntityTitle = N'?'
WHERE EntityTitle = '?'
exec sp_executesql N'SELECT * FROM dbo.AB_Entities ab_e (NOLOCK) INNER JOIN
dbo.AB_EntityTreeNodeLink ab_etl (NOLOCK) ON
ab_e.EntityId=ab_etl.ChildEntityId WHERE ( ab_e.EntityCluster = @.P1) AND (
ab_e.EntityTitle = @.P2 AND ab_e.EntityType = @.P3) ', N'@.P1 int,@.P2
nvarchar(120),@.P3 smallint', 0, N'?', 7
ROLLBACK TRANSACTION
Does it work?
John
"TomX" wrote:
> I use Server2000 and ADO connection and Unicode.
> I have fields type of nvarchar.
> And when I do the search ADO creates the SQL statement like this:
> exec sp_executesql N'SELECT * FROM dbo.AB_Entities ab_e (NOLOCK) INNER JOIN
> dbo.AB_EntityTreeNodeLink ab_etl (NOLOCK) ON
> ab_e.EntityId=ab_etl.ChildEntityId WHERE ( ab_e.EntityCluster = @.P1) AND (
> ab_e.EntityTitle = @.P2 AND ab_e.EntityType = @.P3) ', N'@.P1 int,@.P2
> nvarchar(120),@.P3 smallint', 0, N'?', 7
> (Caught from Profiler)
> And this result nothing.
> but when I delete the N from the second parameter:
> ...., N'@.P1 int,@.P2 nvarchar(120),@.P3 smallint', 0, '?', 7 <-- no N
> before the Unicode variable, it works (work - means result the correct
> records)!
> and to make it more odd
> ..., N'@.P1 int,@.P2 nvarchar(120),@.P3 smallint', 0, N'John', 7 -- with N
> works too.
> I have tested those statements on S2k Query Analyzer and S2k5 SQL Server
> Management Studio Express and there are same results.
> Have anyone any idea what is wrong?
> Regards,
> Tomasz Rutkowski
>
>
>

Wednesday, March 21, 2012

odd TEXT type field problem

Hi,
There is a db with 200GB, with ~160 GB data in it. Most of the data was a
TEXT type field in a table. That field has been dropped and added back with
default NULL but it appears I still have ~160 GB of data.
How is that possible?
updatestats would help?
The table in question has a two field composite clustered index, but not on
the TEXT type field.
The truth is the whole thing is very fragmented. Defragmenting the clustered
index would place exclusive lock on the table?
Your help would be appreciated,
JanosYou can try running DBCC CLEANTABLE on the table that had the TEXT column.
Look up syntax in BOL.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Janos Horanszky" <kob_uki@.hotmail.com> wrote in message
news:emmBIbZEFHA.3368@.TK2MSFTNGP10.phx.gbl...
> Hi,
> There is a db with 200GB, with ~160 GB data in it. Most of the data was a
> TEXT type field in a table. That field has been dropped and added back
with
> default NULL but it appears I still have ~160 GB of data.
> How is that possible?
> updatestats would help?
> The table in question has a two field composite clustered index, but not
on
> the TEXT type field.
> The truth is the whole thing is very fragmented. Defragmenting the
clustered
> index would place exclusive lock on the table?
> Your help would be appreciated,
> Janos
>|||I appreciate Adam, I will try it on our test environment, I let you know
asap.
Janos
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:eDFFq6dEFHA.1012@.TK2MSFTNGP14.phx.gbl...
> You can try running DBCC CLEANTABLE on the table that had the TEXT column.
> Look up syntax in BOL.
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Janos Horanszky" <kob_uki@.hotmail.com> wrote in message
> news:emmBIbZEFHA.3368@.TK2MSFTNGP10.phx.gbl...
> with
> on
> clustered
>

Odd pivot table type query

I've been unable to find a way to write the following
query.
Assuming this table:
Year Quarter
-- --
1990 1
1990 2
1990 3
1990 4
1991 1
1991 2
1991 3
1991 4
Does anyone know how to write an SQL query to generate the
following results?
Year Quarter
-- --
1990 1,2,3,4
1991 1,2,3,4
For documented method, you will have to make use of procedural code to
achieve this. See following example. OR you will have to use some 3rd party
tool to do it(www.rac4sql.com).
Eg:
-- sample table
-- if object_id('tab') is not null
-- drop table tab
create table tab(ID int,
SEQ_NUM int ,
ROUTE varchar(50))
go
-- sample data
insert into tab values(1 ,1 ,'AA')
insert into tab values(1 ,2 ,'BB')
insert into tab values(1 ,3 ,'CC')
insert into tab values(2 ,1 ,'AA')
insert into tab values(3 ,1 ,'VV')
insert into tab values(3 ,2 ,'XX')
go
-- t-sql code for generating report
if object_id('tempdb..#tmp') is not null
drop table #tmp
create table #tmp(id int, tmpval varchar(50))
go
declare @.id int
declare @.seq_num int
declare @.route varchar(50), @.f_route varchar(50)
select @.id=0, @.seq_num=0, @.route='', @.f_route=''
while @.id is not null
begin
select @.id=min(id) from tab where id > @.id
while @.seq_num is not null
begin
select @.seq_num=min(seq_num), @.route=min(route)from tab where id = @.id
and seq_num > @.seq_num
If @.seq_num is null and @.id is not null
insert into #tmp values(@.id, @.f_route)
select @.f_route = @.f_route + case @.f_route when '' then '' else ','
end + @.route
end
select @.seq_num=0, @.f_route=''
end
select * from #tmp
truncate table #tmp
Vishal Parkar
vgparkar@.yahoo.co.in | vgparkar@.hotmail.com
|||Thanks for the response Vishal. Unfortunatly this
solution isn't going to work for me since I dealing with a
very large number of records the performace of populating
a new table is going to be too great.
I'm adding a "download" feature for the data so this would
result is a large number of records being retuned and
written to file.
What would be great is is I could use somethine like a
GROUP BY and SUM where the SUM would append strings
together.
SELECT year, APPEND(Quarter)
FROM mytable
GROUP BY year

>--Original Message--
>For documented method, you will have to make use of
procedural code to
>achieve this. See following example. OR you will have to
use some 3rd party
>tool to do it(www.rac4sql.com).
>Eg:
>-- sample table
>-- if object_id('tab') is not null
>-- drop table tab
>create table tab(ID int,
>SEQ_NUM int ,
>ROUTE varchar(50))
>go
>-- sample data
>insert into tab values
(1 ,1 ,'AA')
>insert into tab values
(1 ,2 ,'BB')
>insert into tab values
(1 ,3 ,'CC')
>insert into tab values
(2 ,1 ,'AA')
>insert into tab values
(3 ,1 ,'VV')
>insert into tab values
(3 ,2 ,'XX')
>go
>-- t-sql code for generating report
>if object_id('tempdb..#tmp') is not null
>drop table #tmp
>create table #tmp(id int, tmpval varchar(50))
>go
>declare @.id int
>declare @.seq_num int
>declare @.route varchar(50), @.f_route varchar(50)
>select @.id=0, @.seq_num=0, @.route='', @.f_route=''
>while @.id is not null
>begin
> select @.id=min(id) from tab where id > @.id
> while @.seq_num is not null
> begin
> select @.seq_num=min(seq_num), @.route=min(route)from
tab where id = @.id
> and seq_num > @.seq_num
> If @.seq_num is null and @.id is not null
> insert into #tmp values(@.id, @.f_route)
> select @.f_route = @.f_route + case @.f_route when ''
then '' else ','
>end + @.route
> end
> select @.seq_num=0, @.f_route=''
>end
>select * from #tmp
>truncate table #tmp
>--
>Vishal Parkar
>vgparkar@.yahoo.co.in | vgparkar@.hotmail.com
>
>.
>
|||Shawn,
There is no function as such which will do the things for you.
You may try following approach using User defined function. But remember,
this is not a documented method, so it can not be reliable under all
cirumstances.
CREATE FUNCTION EmpPhones (@.ID INT)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @.str VARCHAR(1000)
SELECT @.str = ISNULL(@.str + ',', '') + cats
FROM tab WHERE id = @.ID
RETURN (@.str)
END
-- sample data / result set.
if object_id ('tab') is not null
drop table tab
go
create table tab(ID int,
cats varchar(50))
go
insert into tab values(1 ,'1-001')
insert into tab values(1 ,'2-002')
insert into tab values(1 ,'3-003')
insert into tab values(2 ,'1-011')
insert into tab values(3 ,'1-012')
insert into tab values(3 ,'2-022')
go
--And then you would call this UDF from within a SELECT statement, as
follows:
select distinct id,dbo.empphones(id) 'comma seperated value' from tab
Vishal Parkar
vgparkar@.yahoo.co.in | vgparkar@.hotmail.com

Monday, March 12, 2012

ODBCBCP Driver Mismatch

Hello,
I am receiving the following error message whenever I try to replicate using Snapshot repl. (or any type of replication) from the snapshot agent:
Error Message: The process could not bulk copy out of table '[dbo].[syncobj_xxxxxxxx]'.
Error Details: ODBCBCP/Driver version mismatch
(Source: ODBC SQL Server Driver (ODBC); Error number: 0)
I have checked the versions of the odbcbcp.dll on both of my SQL Servers (both of which are win2k3 w/ SQL Server 2000 sp3) and they are both 2000.85.1022.0. The version number of sqlsrv32.dll and sqlsrv32.rll are 2000.85.1025.0. Do all three have to mat
ch, is that my problem? Please HELP!! I can't replicate at all!
there are some reports that this problem can be solved by upgrading to a
consistent MDAC versions on both machines.
"Paul Pelletier" <anonymous@.discussions.microsoft.com> wrote in message
news:3E372B82-39B2-4A93-B7DE-5B7740527F13@.microsoft.com...
> Hello,
> I am receiving the following error message whenever I try to replicate
using Snapshot repl. (or any type of replication) from the snapshot agent:
> Error Message: The process could not bulk copy out of table
'[dbo].[syncobj_xxxxxxxx]'.
> Error Details: ODBCBCP/Driver version mismatch
> (Source: ODBC SQL Server Driver (ODBC); Error number: 0)
> I have checked the versions of the odbcbcp.dll on both of my SQL Servers
(both of which are win2k3 w/ SQL Server 2000 sp3) and they are both
2000.85.1022.0. The version number of sqlsrv32.dll and sqlsrv32.rll are
2000.85.1025.0. Do all three have to match, is that my problem? Please
HELP!! I can't replicate at all!
|||Hillary,
I have, I re-applied MDAC 2.7 on both SQL Servers and still the same problem. Any other possible solutions?
Do all there files have to have the same version numbers?
Thanks,
Paul
|||Check the version of the ODBC32.dll. It could be the one that is
mismatched. It should be version 3.525.1022.0.
Rand
This posting is provided "as is" with no warranties and confers no rights.
|||It is mismatched in a sense. The odbcbcp.dll is version 2000.85.1022.0. The sqlsrv32.dll is 2000.85.1025.0. The sqlsrv32.rll is 2000.85.1025.0. So really the one that is mismatched is the sqlsrv32.dll, but which version should be the correct version f
or all three, the 1025 or 1022?
Thanks again,
Paul
|||Sorry about the previous post, I did not completely read your post and I missed the fact that you were talking about a completely different dll, I'm a tard! Anyway both of the odbc32.dll do match on both machines and they are in fact 3.525.1022.0. Where
now?

Monday, February 20, 2012

ODBC insert of SQL_TYPE_TIMESTAMP

Hi,
I'm trying to insert a time stamp into SQL Server (2005) and can't figure
out the right combination of column type and arguments to SQLBindParameter()
.
My C code currently looks like this:
rc = SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT,
SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 10, 0,
(SQLPOINTER)&tstamp, 0, NULL);
I've tried different values for the ColumnSize and DecimalDigits parameters,
including 10, 19, 22, 23, 26, and SQL_TIMESTAMP_LEN.
As for the table definition, I've tried DateTime, char(10), char(19), etc.
Different combinations either give me return codes of 22008 or 42S02.
I definitely need to insert into a single column, as I'm trying to maintain
compatibility with an equivalent DB2 database (which, if it helps, uses the
DB2 TIMESTAMP data type, and has no problem with the above code).
Info on the web for this problem is surprisingly scarce. I've found a few
things but nothing concrete - so I'd really appreciate any help.
Thanks in advance!
Regards,
Josh"LDJ" <LDJ@.discussions.microsoft.com> wrote in message
news:37FA6F9F-2352-4F86-B79C-6C262D8099A0@.microsoft.com...
> Hi,
> I'm trying to insert a time stamp into SQL Server (2005) and
> can't figure
> out the right combination of column type and arguments to
> SQLBindParameter().
> My C code currently looks like this:
> rc = SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT,
> SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, 10, 0,
> (SQLPOINTER)&tstamp, 0, NULL);
> I've tried different values for the ColumnSize and
> DecimalDigits parameters,
> including 10, 19, 22, 23, 26, and SQL_TIMESTAMP_LEN.
> As for the table definition, I've tried DateTime, char(10),
> char(19), etc.
> Different combinations either give me return codes of 22008 or
> 42S02.
This is probably a little more than you want to see, but ...
We use our own DB objects to encapsulate ODBC access to Oracle,
DB2 and SQL Server (2000). Therefore, some extra code you won't
recognize. But, I think you're just looking for the Bind.
Please see below.
////////////////////////////////////////////////////////////////////////////
/
//
void VParameter::PutDateTime( VDateTime dateTime )
{
SQLRETURN rc;
USHORT msec;
m_LenInd = sizeof( m_timeStamp );
dateTime.DecodeDate( m_timeStamp.year, m_timeStamp.month,
m_timeStamp.day );
dateTime.DecodeTime( m_timeStamp.hour, m_timeStamp.minute,
m_timeStamp.second, msec );
m_timeStamp.fraction = 0;
rc = SQLBindParameter( m_hStmt, m_paramNumber,
SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_TIMESTAMP,
sizeof( "yyyy-mm-dd hh:mm:ss" ), 0,
&m_timeStamp, sizeof( m_timeStamp ), (SQLLEN *) &m_LenInd);
CHECK_STMT( m_hStmt, rc );
}
m_timeStamp is just the SQL timestamp struct. A VDateTime is our
own object, based on midnight Dec. 30, 1899 (that's a standard).
m_* are class variables.
Good luck,
- Arnie|||Hi,
This is what I used for my SQLBindParameter and it's working, so hope it'll
help you!
SQLBindParamenter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TIMESTAMP, SQL_TIMESTAMP,
0, 0, (SQLPOINTER)&value, 0, &cbSize);
Note: columnSize and bufferLength are ignored when the type is
SQL_TIMESTAMP, cbSize is just an SQLINTEGER but asyou know it's also ignored
for timestamps...
I'm not sure whether it makes a difference if you use SQL_C_TIMESTAMP as
opposed to SQL_C_TYPE_TIMESTAMP, but I've been using the former
Hope this helps,
Isabella
P.S. you can check out the following on the function if you haven't already:
http://msdn.microsoft.com/library/d...ndparameter.asp
"Arnie" wrote:

> "LDJ" <LDJ@.discussions.microsoft.com> wrote in message
> news:37FA6F9F-2352-4F86-B79C-6C262D8099A0@.microsoft.com...
> This is probably a little more than you want to see, but ...
> We use our own DB objects to encapsulate ODBC access to Oracle,
> DB2 and SQL Server (2000). Therefore, some extra code you won't
> recognize. But, I think you're just looking for the Bind.
> Please see below.
> //////////////////////////////////////////////////////////////////////////
///
> //
> void VParameter::PutDateTime( VDateTime dateTime )
> {
> SQLRETURN rc;
> USHORT msec;
> m_LenInd = sizeof( m_timeStamp );
> dateTime.DecodeDate( m_timeStamp.year, m_timeStamp.month,
> m_timeStamp.day );
> dateTime.DecodeTime( m_timeStamp.hour, m_timeStamp.minute,
> m_timeStamp.second, msec );
> m_timeStamp.fraction = 0;
> rc = SQLBindParameter( m_hStmt, m_paramNumber,
> SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_TIMESTAMP,
> sizeof( "yyyy-mm-dd hh:mm:ss" ), 0,
> &m_timeStamp, sizeof( m_timeStamp ), (SQLLEN *) &m_LenInd);
> CHECK_STMT( m_hStmt, rc );
> }
>
> m_timeStamp is just the SQL timestamp struct. A VDateTime is our
> own object, based on midnight Dec. 30, 1899 (that's a standard).
> m_* are class variables.
> Good luck,
> - Arnie
>
>
>|||Oops sorry LDJ
My columnsize is set to sizeof(TIMESTAMP_STRUCT), not 0... and i was
incorrect, ColumnSize is not ignored for SQL_TIMESTAMP!
Sorry for the confusion.
Isabella
"Isa" wrote:
[vbcol=seagreen]
> Hi,
> This is what I used for my SQLBindParameter and it's working, so hope it'l
l
> help you!
> SQLBindParamenter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TIMESTAMP, SQL_TIMESTAM
P,
> 0, 0, (SQLPOINTER)&value, 0, &cbSize);
> Note: columnSize and bufferLength are ignored when the type is
> SQL_TIMESTAMP, cbSize is just an SQLINTEGER but asyou know it's also ignor
ed
> for timestamps...
> I'm not sure whether it makes a difference if you use SQL_C_TIMESTAMP as
> opposed to SQL_C_TYPE_TIMESTAMP, but I've been using the former
> Hope this helps,
> Isabella
> P.S. you can check out the following on the function if you haven't alread
y:
> http://msdn.microsoft.com/library/d...ndparameter.asp
>
> "Arnie" wrote:
>|||Apologies to Josh and Arnie! I realised the reason why my code worked was
because I was just inserting a date with no time...
Josh, Arnie was correct, the column size should be 19 as it actually
represents the number of bytes needed to display the yyyy-mm-dd hh:mm:ss
format.. If you wanted to show the fraction, you should use 20 + s as the
columnSize, where s is the precision
http://msdn.microsoft.com/library/d.../>
mn_size.asp
Sorry for my unhelpful posts b4
Isabella
"Isa" wrote:
[vbcol=seagreen]
> Oops sorry LDJ
> My columnsize is set to sizeof(TIMESTAMP_STRUCT), not 0... and i was
> incorrect, ColumnSize is not ignored for SQL_TIMESTAMP!
> Sorry for the confusion.
> Isabella
> "Isa" wrote:
>