Quantcast
Channel: SQL Server Data Access forum
Viewing all 4164 articles
Browse latest View live

SQL SERVER How to combine two tables in a certain order

$
0
0

Hi:

I have a store procedure where I’m trying to combine two tables in a certain order. I have results from one table:

EMP_ID HOL_ID HOLIDAY_TITLE            HOLIDAY_DATE          DATE_HOLIDAY_SUBMIT    HOLIDAY_REQUESTED
NULL     NULL     Labor Day, 2013           2013-09-02                NULL                               NULL
NULL     NULL    Election Day, 2013          2013-11-05               NULL                              NULL
NULL     NULL    News Years Day, 2014     2014-01-01               NULL                               NULL
NULL     NULL    Martin Luther King,          2014-01-20               NULL                              NULL
                       Jr. Birthday, 2014
NULL    NULL     Presidents Day,  2014     2014-02-17                NULL                               NULL
NULL    NULL     4th of July, 2014            2014-07-04                NULL                               NULL
NULL    NULL     Labor Day, 2014           2014-09-01                  NULL                                NULL
NULL    NULL     Election Day, 2014        2014-11-04                  NULL                               NULL
NULL    NULL     Christmas,2014            2014-12-25                   NULL                               NULL
100015 608     Thanksgiving Day, 2013 2013-11-28                2014-08-16                     2014-08-04
100015 609     Christmas, 2013           2013-12-25                 2014-08-16                       2014-08-05
100015 614     Memorial Day,  2014     2014-05-26                  2014-08-16                      2014-08-06
100015 613     Easter, 2014                 2014-04-20                  2014-08-16                    2014-08-07
100015 600     News Years Day, 2013 2013-01-01                    2014-08-16                      2014-09-22
100015 601    Martin Luther King,       2013-01-21                     2014-08-16                    2014-09-23 
                  Jr. Birthday, 2013
100015 604     Memorial Day, 2013     2013-05-27                   2014-08-16                        2014-11-19
100015 605    4th of July, 2013           2013-07-04                       2014-08-16                  2014-11-20
100015 618    Thanksgiving Day, 2014 2014-11-27                       2014-08-16                 2014-12-03
100015 602     Presidents Day, 2013    2013-02-18                      2014-08-16                2014-12-09
100015 603     Easter, 2013                2013-03-31                       2014-08-16                2014-12-10

when I run this part of the stored procedure:

SELECT HO.EMP_ID_NUM,  HO.HOLIDAY_ID,CH.HOLIDAY_TITLE, CH.HOLIDAY_DATE, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED,
  HOLIDAY_APPROVED, HOL_APPROVAL_DATE, HOLIDAY_CANCEL, HOLIDAY_CANCEL_DATE
  FROM COMPANY_HOLIDAY CH LEFT OUTER JOIN HOLIDAY_OFF HO
  ON HO.HOLIDAY_ID = CH.HOLIDAY_ID
  AND HO.EMP_ID_NUM = 100015
  ORDER BY HO.HOLIDAY_REQUESTED

I get these results:

HOLIDAY_ID HOLIDAY_TITLE             HOLIDAY_DATE
600  News Years Day                       2013-01-01
601  Martin Luther King, Jr. Birthday 2013-01-21
602  Presidents Day                       2013-02-18
603  Easter                                2013-03-31
604  Memorial Day                      2013-05-27
605  4th of July                         2013-07-04
606  Labor Day                          2013-09-02
607  Election Day                         2013-11-05
608  Thanksgiving Day                2013-11-28
609  Christmas                           2013-12-25
610  News Years Day                  2014-01-01
611  Martin Luther King, Jr. Birthday 2014-01-20
612  Presidents Day                      2014-02-17
613  Easter                                2014-04-20
614  Memorial Day                           2014-05-26
615  4th of July                             2014-07-04
616  Labor Day                        2014-09-01
617  Election Day                      2014-11-04
618  Thanksgiving Day                  2014-11-27
619  Christmas                          2014-12-25

When I run this part of the stored procedure:

 SELECT HOLIDAY_ID,  HOLIDAY_TITLE, HOLIDAY_DATE
  FROM COMPANY_HOLIDAY
  ORDER BY HOLIDAY_DATE

The result that I want to get is this:

HOLIDAY_ID HOLIDAY_TITLE            HOLIDAY_DATE    DATE_HOLIDAY_SUBMIT    HOLIDAY_REQUESTED
600  News Years Day                       2013-01-01            2014-08-16                     2014-08-04 
601  Martin Luther King, Jr. Birthday 2013-01-21               2014-08-16                2014-08-05 
602  Presidents Day                        2013-02-18                2014-08-16                2014-08-06 
603  Easter                                   2013-03-31                 2014-08-16                     2014-08-07 
604  Memorial Day                          2013-05-27              2014-08-16                   2014-09-22 
605  4th of July                             2013-07-04                 2014-08-16                  2014-09-23 
606  Labor Day                             2013-09-02                 2014-08-16                    2014-11-19 
607  Election Day                          2013-11-05                 2014-08-16                  2014-11-20 
608  Thanksgiving Day                    2013-11-28                 2014-08-16                  2014-12-03 
609  Christmas                              2013-12-25                 2014-08-16                    2014-12-09 
610  News Years Day                      2014-01-01                2014-08-16                       2014-12-10 
611  Martin Luther King, Jr. Birthday 2014-01-20                   NULL                               NULL
612  Presidents Day                         2014-02-17                  NULL                               NULL
613  Easter                                    2014-04-20                   NULL                                 NULL
614  Memorial Day                        2014-05-26                    NULL                                  NULL
615  4th of July                                2014-07-04                 NULL                                    NULL
616  Labor Day                                2014-09-01                    NULL                                 NULL
617  Election Day                            2014-11-04                        NULL                           NULL
618  Thanksgiving Day                      2014-11-27                        NULL                             NULL
619  Christmas                                2014-12-25                       NULL                             NULL

Here is my store procedure that won't the way I want it to work:

GO

CREATE PROCEDURE  proc_MoveEmOnUp(@employeeID INTEGER)
AS
BEGIN
DECLARE @holidayChosen TABLE
(
employID   INTEGER,
holidayID   INTEGER,
holidayTitle   VARCHAR (40),
holidayDate   DATE,
holidaySubmitDate  DATE,
holidayDateRequest  DATE,


PRIMARY KEY (employID, holidayID)
);

DECLARE @employID   INTEGER,
  @holidayID  INTEGER,
  @holidayTitle  VARCHAR(40),
  @holidayDate  DATE,
  @holidaySubmitDate DATE,
  @holidayDateRequest DATE,
  
  
DECLARE @holidayList TABLE
(
holiday_ID   INTEGER,
holiday_Title   VARCHAR(40),
holiday_Date   DATE


PRIMARY KEY (holiday_ID)
);

DECLARE
  @holiday_ID INTEGER,
  @holiday_Title VARCHAR(40),
  @holiday_Date DATE
  
  
  
DECLARE @holidays TABLE
(
empID   INTEGER,
holID   INTEGER,
holTitle  VARCHAR(40),
holDate   DATE,
holSubmitDate  DATE,
holDateRequest  DATE,


PRIMARY KEY (empID, holID)
);

DECLARE @empID   INTEGER,
 @holID   INTEGER,
 @holTitle  VARCHAR(40),
 @holDate  DATE,
 @holSubmitDate  DATE,
 @holDateRequest  DATE,
 
 
 LOCAL STATIC FORWARD_ONLY READ_ONLY
 FOR
 
  SELECT HO.EMP_ID_NUM,  HO.HOLIDAY_ID,CH.HOLIDAY_TITLE, CH.HOLIDAY_DATE, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED
  FROM COMPANY_HOLIDAY CH LEFT OUTER JOIN HOLIDAY_OFF HO
  ON HO.HOLIDAY_ID = CH.HOLIDAY_ID
  AND HO.EMP_ID_NUM = 100015
  ORDER BY HO.HOLIDAY_REQUESTED
  
OPEN c;
 FETCH NEXT FROM c INTO @employID, @holidayID, @holidayTitle, @holidayDate, @holidaySubmitDate,  @holidayDateRequest
 
WHILE @@FETCH_STATUS = 0
BEGIN
   
 INSERT @holidayChosen(employID, holidayID, holidayTitle, holidayDate, holidaySubmitDate, holidayDateRequest)
 SELECT @employID, @holidayID, @holidayTitle, @holidayDate, @holidaySubmitDate,  @holidayDateRequest
 FETCH NEXT FROM c INTO @employID, @holidayID, @holidayTitle, @holidayDate, @holidaySubmitDate,  @holidayDateRequest
 
 END;
 
 CLOSE c;
DEALLOCATE c;

DECLARE c_Cursor CURSOR
LOCAL STATIC FORWARD_ONLY READ_ONLY
FOR
 SELECT HOLIDAY_ID,  HOLIDAY_TITLE, HOLIDAY_DATE
  FROM COMPANY_HOLIDAY
  ORDER BY HOLIDAY_DATE

 
OPEN c_Cursor

FETCH NEXT FROM c_Cursor INTO @holiday_ID, @holiday_Title, @holiday_Date;

WHILE @@FETCH_STATUS = 0
BEGIN

INSERT  @holidayList(holiday_ID, holiday_Title, holiday_Date)

 SELECT @holiday_ID, @holiday_Title, @holiday_Date;
 FETCH NEXT FROM c_Cursor INTO @holiday_ID, @holiday_Title, @holiday_Date;
 END;
 
 CLOSE c_Cursor;
DEALLOCATE c_Cursor

DECLARE d CURSOR
LOCAL STATIC FORWARD_ONLY READ_ONLY
FOR

SELECT HC.employID, HL.holiday_ID, HL.holiday_Title, HL.holiday_Date, HC.holidaySubmitDate, HC.holidayDateRequest,
       FROM @holidayList HL, @holidayChosen HC
       WHERE HC.holidayDateRequest IS NOT NULL
 
 
OPEN d

FETCH NEXT FROM d INTO @empID, @holID, @holTitle, @holDate, @holSubmitDate, @holDateRequest

WHILE @@FETCH_STATUS = 0
BEGIN


INSERT  @holidays(empID, holID, holTitle,  holDate, holSubmitDate, holDateRequest)

 SELECT @empID, @holID, @holTitle, @holDate, @holSubmitDate, @holDateRequest)
 FETCH NEXT FROM d INTO @empID, @holID, @holTitle, @holDate, @holSubmitDate, @holDateRequest)
 
 END;
 
 CLOSE d;
 
SELECT empID, holID, holTitle, holDate, holSubmitDate, holDateRequest
FROM @holidays
WHERE empID = @employeeID
END;
GO

Here are my tables:


CREATE TABLE COMPANY_HOLIDAY(
HOLIDAY_ID  INTEGER NOT NULL,
HOLIDAY_TITLE VARCHAR(40),
HOLIDAY_DATE DATETIME2(0)

PRIMARY KEY(HOLIDAY_ID),
);

CREATE TABLE HOLIDAY_OFF(
EMP_ID_NUM    INTEGER NOT NULL,
HOLIDAY_ID    INTEGER NOT NULL,
DATE_HOLIDAY_SUBMIT  DATETIME2(0) DEFAULT GETDATE(),
HOLIDAY_REQUESTED  DATETIME2(0)


PRIMARY KEY(EMP_ID_NUM, HOLIDAY_ID),
FOREIGN KEY(HOLIDAY_ID) REFERENCES  COMPANY_HOLIDAY(HOLIDAY_ID),

);

Here's some data:


-- 2013 Company Holidays
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(600, 'News Years Day', '01-Jan-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(601, 'Martin Luther King, Jr. Birthday','21-Jan-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(602, 'Presidents Day','18-Feb-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(603, 'Easter', '31-Mar-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(604, 'Memorial Day','27-May-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(605, '4th of July', '04-Jul-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(606, 'Labor Day','02-Sep-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE)VALUES(607, 'Election Day', '05-Nov-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(608, 'Thanksgiving Day','28-Nov-2013');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(609, 'Christmas','25-Dec-2013');


-- 2014
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(610, 'News Years Day','01-Jan-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(611, 'Martin Luther King, Jr. Birthday', '20-Jan-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(612, 'Presidents Day','17-Feb-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(613, 'Easter', '20-Apr-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(614, 'Memorial Day','26-May-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(615, '4th of July', '04-Jul-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(616, 'Labor Day', '01-Sep-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(617, 'Election Day','04-Nov-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(618, 'Thanksgiving Day', '27-Nov-2014');
INSERT INTO COMPANY_HOLIDAY(HOLIDAY_ID, HOLIDAY_TITLE, HOLIDAY_DATE) VALUES(619, 'Christmas','25-Dec-2014');

INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 608, 'Thanksgiving Day, 2013', '2013-11-28', GETDATE(), '2014-08-04');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 609, 'Christmas, 2013', '2013-12-25', GETDATE(), '2014-08-05');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 614, 'Memorial Day, 2014', '2014-05-26', GETDATE(), '2014-08-06');

INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 613, 'Easter, 2014', '2014-04-20', GETDATE(), '2014-08-07');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 600, 'News Years Day, 2013', '2013-01-01', GETDATE(), '2014-09-22');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 601, 'Martin Luther King,Jr.Birthday, 2013', '2013-01-21', GETDATE(), '2014-09-23');

INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 604, 'Memorial Day, 2013', '2013-05-27', GETDATE(), '2014-11-19');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 605, '4th of July, 2013', '2013-07-04', GETDATE(), '2014-11-20');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 618, 'Thanksgiving Day, 2014', '2014-11-27', GETDATE(), '2014-12-03');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 602, 'Presidents Day, 2013', '2013-02-18', GETDATE(), '2014-12-09');
INSERT INTO HOLIDAY_OFF(EMP_ID_NUM, HOLIDAY_ID, DATE_HOLIDAY_SUBMIT, HOLIDAY_REQUESTED) VALUES (100015, 603, 'Easter, 2013', '2013-03-31', GETDATE(), '2014-12-10');

Thank you very much for your time and expertise.

Sincerely,

Bosco Dog


Getting SQLSTATE:22001(Message : [Microsoft][SQL Server Native Client 11.0]String data, right truncation) in SQL Server 2012 but in SQL server 2008 R2.

$
0
0

I have an application which connects to SQL through ODBC 11.

ODBC statement is :

SELECT PID
FROM PENTITY PENTITY01 WHERE ((NUM1 NOT BETWEEN ? + 10.7895 AND ? + 200.6734 AND NUM2 NOT IN (5996/ 8, ? - 89.3892, ? + 80.7543))

and the SQLBindparameter statement is :

static UCHAR num1[12]=12.589

rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, sqlType, precision, scale,
&num1, sizeof(num1), NULL);

With this SQLBindparameter statement I am getting error, It is working without any error if I change the value to 12.

The same code is working when connecting to SQL server 2008.

Thanks in advance.


Batchsize limit for SQL JDBC sqljdbc4-4.0

$
0
0

Is there any limit on number of records in a JDBC batch?

I am using sqljdbc4-4.0 to connect with SQL Server 2012 DB.

Please point me to reference documentation for this, if available.

Thanks,

Dhananjay


Microsoft® SQL Server® ODBC Driver 1.0 for Linux problem

$
0
0

Hello! I've RedHat Linux 6 Update 1 x64 on VMware Player and MS SQL Server on real machine. My application "servernew" on RedHat. All right, but when i try connect my SQL Server:
retcode = SQLDriverConnect(hdbc,NULL,string,sizeof(string),buf,sizeof(buf),&StringLength2,SQL_DRIVER_NOPROMPT);
i get retocde = -1;
Using SQLGetDiagRec:
MessageText = Data source name not found, and no default driver specified

To make my connection i use next attempts for connection string:
//char constring[200]="Driver={Microsoft Server ODBC Driver 1.0 for Linux};Server=ARTPK2\\SQLEXPRESS2;Database=Kurs;Uid=sa;Pwd=2ef5Fese";
//char constring[200]="Driver={SQL Server Native Client 11.0};Server=ARTPK2\\SQLEXPRESS2;Database=Kurs;Uid=sa;Pwd=2ef5Fese";
//char constring[200]="Driver={Microsoft SQL Server ODBC Driver V1.0 for Linux};Server=ARTPK2\\SQLEXPRESS2;Database=Kurs;Uid=sa;Pwd=2ef5Fese";
//char constring[200]="Driver={/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0};Server=ARTPK2\\SQLEXPRESS2;Database=Kurs;Uid=sa;Pwd=2ef5Fese";
char constring[200]="DSN={SQL Server Native Client 11.0};Uid=sa;Pwd=2ef5Fese";

but...Data source name not found, and no default driver specified .. help me

getParameterMetaData: The multi-part identifier could not be bound.

$
0
0
HI,

I came to know from your forums.

This(getParameterMetaData: The multi-part identifier "a.d2" count not be bound) is bug in driver.
I am using sqljdbc4 driver and also facing the same issue. Still the driver has  the same issue ?

Thanks,

Noorul.

Access->ODBC->SQL "untrusted domain" 18452 error

$
0
0

I have a number of client databases written in MS Access connecting via ODBC to SQL 2008. The databases were originally developed on WinXP and Access 2003. They were used successfully when opened on Vista and Windows 7 on machines that are actually on the domain. The problem began when I upgraded my own development machine to Windows 7. I began receiving the now-famous 18452 error -- that I couldn't connect to the database from an untrusted domain.

Because I am a consultant and contractor with numerous clients, attaching to the domain is less-than-preferable. (In some cases, it might even be a violation of security and NDA issues with other clients.) Therefore, I need to be able to continue to develop and use these databases in the manner that I was able to do before.

This is the particulars and what I have tried/determined so far:

  • The SQL server is in mixed mode authentication -- which is why I have been able to do this for 3 years.
  • I can connect to the server (and other servers on the domain) and browse directories, etc. as long as I use a login prompt with my domain ID. This used to be enough to then permit connection to the SQL server. However, in Windows 7, this is no longer the case.
  • I can connect to the SSMS using SQL Authentication.
  • I can connect to the SMSS using Windows Authentication if I use the much-publicized "runas /netonly" hack. (This hack is not usable, however, for an Access mdb or mde file because you can only use it for exe files.)
  • I can connect via ODBC from Access if I use SQL Authentication.
  • I have added the connection information for the domain and all servers in the (apparently useless) Credential Manager to no avail.
So, it seems that what has changed is something particular to the way Windows 7 stores credentials. The seeming contradiction is that I can get to all the files, folders, shares, printers, etc. on all the domain machine (including the one that hosts the SQL server), but can NOT connect to the SQL server at all. That seems a little odd to me.

So, is there something that needs to change on either my machine, the server, the domain, or in the SQL configuration in order to recognize my machine as being allowed in the same fashion that it is for the other network fashions above?


Dave Mark -- Intrinsic Algorithm LLC

command timeout

$
0
0

I am getting a timeout on the following .Net code:

static void Main(string[] args)
{
	string sConn = "Data Source=myserver;Initial Catalog=MyDB;Integrated Security=True";
	using(var conn = new SqlConnection(sConn) )
	{
		conn.Open();
		var cmd = new SqlCommand("dbo.spTest",conn);
		cmd.CommandType = CommandType.StoredProcedure;
		cmd.CommandTimeout = 1000;
		SqlCommandBuilder.DeriveParameters(cmd);

		var par = cmd.Parameters[1];
	}
}
Query timeout occurs an any stored proc added or altered after the database was restored to a test server. All queries fail, eg cmd.ExecuteNonQuery(). I just used DeriveParameters as an example.  When testing procs untouched since before the restore, all queries work fine.  What could cause this?

Need to close all open ODBC connectons to SQL server when Access 2010 database closes

$
0
0

Hi there, we are currently having an issue with several Access 2010 databases that are using pass through queries to a SQL server 2008 database.

When the pass through queries runs the memory on the server will spike.  After the query completes & even after Access has been shut down, the memory is not released until we restart the SQL DB services. (this can be a select, update query)

What I would like to do is create code that will close all open ODBC connections to the DB when the Access database closes in hopes this will help release the memory when the database closes.


Not able to login from client system

$
0
0

We have a server which is windows server 2003 for ERP(VB) software and Ms Sql 2002 running under workgroup computer. Now company bought a server for Ms 2008 ads domain. My question is client user can connect as usual if i configure that win2003 server into 2008 domain computer?

Thanks in advance.

        

Not able to login from client system

$
0
0

not able to login and access erp (VB) and sql server 2003 software from client system since we have changed windows 2003 server from workgroup to another domain. What is the cause of this issue?

Thanks in advance.



SQL Server 2005 Error: 17886, Severity: 20, State: 1

$
0
0
Hi.

We are running ASP.NET 3.5 with nHibernate 2.0 and using separate SQLDataReaders.  All SQLClient connections are going through a single connection string using MARS (MultipleActiveResultSets=true).

On SQL Server we are seeing many exceptions with the following error:

Error: 17886, Severity: 20, State: 1

The server will drop the connection, because the client driver has sent multiple requests while the session is in single-user mode. This error occurs when a client sends a request to reset the connection while there are batches still running in the session, or when the client sends a request while the session is resetting a connection. Please contact the client driver vendor.

bcp_bind fails when used with size over 8000 bytes for VARBINARY(MAX) column

$
0
0

Hi,

I am using a Bulk Copy Functions (http://msdn.microsoft.com/en-us/library/ms130922.aspx) via SQL Server native client v11 for fast data insertion into SQL Server 2012 table. Everything works fine, except insertion of big (over 8K) data chunks into BLOB column (inserting data under 8K works without any issues). I get following extended information about the error:


HY000 „Invalid field size for datatype“

Example C++ code:

std::vector<char> vData(9000, 0);
BYTE* pData = &buf[0];
DBINT nLenth = buf.size();
auto nRet = bcp_bind(hHandle, pData, 0, nLength, nullptr, 0, SQLVARBINARY, 2/*Column number is correct*/);
assert(nRet != FAIL); //Fails

Table creation SQL:

CREATE TABLE [Table1] (C1 INT IDENTITY (1,1) NOT NULL, C2 VARBINARY(MAX) NULL);

I’ve tried different data type valus (SQLBIGBINARY, SQLBIGVARBINARY, SQLBINARY, …) – same error.

I’ve tried setting „pData“ to „nullptr“ to signal that data will be provided via calls to „bcp_moretext“ - same error.

Transferring same data via ODBC SQLBindParameter with type SQL_VARBINARY (SQL_C_BINARY) works without any problems.

Any chance to get bulk copy functionality working?

Thank you!

Roman

AUDITINg IN SQL 2008

$
0
0

Hi ,

is there a way to audit users are member in the Sysadmin role using SQL auditing ?

Report Parameters with a space between, not working

$
0
0

I have a problem with a report in SQL Server 2012 that uses cascading multi-valued parameters. I am using AdventureWorks2012DW as a sample, and all parameters work except for one with a space in this case its SalesTerritoryCountry and the parameter is 'North America' which has a space. How do i get it to return data? here is my Stpre procedure for you to try.

Create Procedure dbo.uspReportParams
(
	@Region varchar(15),
	@Country varchar(60)
)
AS
BEGIN
SET NOCOUNT ON
Select st.SalesTerritoryGroup [Region], st.SalesTerritoryCountry [Country], r.BusinessType [Business Type], SUM(rs.SalesAmount) [Sales Amount]
from DimReseller r join FactResellerSales rs on r.ResellerKey = rs.ResellerKey
join DimDate d on rs.OrderDateKey = d.DateKey
join DimProduct p on p.ProductKey = rs.ProductKey
join DimSalesTerritory st on rs.SalesTerritoryKey = st.SalesTerritoryKey
where st.SalesTerritoryGroup IN (Select [splitdata] FROM dbo.fnSplitString (@Region,', '))
--AND st.SalesTerritoryGroup <> 'NA'
AND st.SalesTerritoryCountry IN (Select [splitdata] FROM dbo.fnSplitString (@Country,', '))
Group by st.SalesTerritoryGroup, st.SalesTerritoryCountry, r.BusinessType
END

IF i check it with other parameters it works except for North America

EXEC dbo.uspReportParams @Region = 'Europe,Pacific,North America', @Country = 'Germany,France,United Kingdom,Australia,Canada'

ODBC Driver Not connecting to SQL Server

$
0
0

I have an app using ODBC 32 bit connection to SQL Server 2008.

At one of my client, all the workstation except one is connecting well to the server using ODBC32 bit System DSN.

One of the workstation, show the server on dropdown list but doesn't connect. I have disabled the firewall on the workstation to eliminate the security issue.

The workstation is Windows 7 so I tried to make the same connection using ODBC 64bit driver and the System DSN connected without any problem.

Is there a way  I can remove and resinstall 32 bit version of ODBC? or any alternate solution someone can provlde..

Thanks,


JDBC driver licence.jar missing

$
0
0

Hello,

I have a problem to install JDBC driver to SAP Netweaver. I downloaded driver from Microsoft pages but there is missing licence.jar file. Could you please help me with this issue?

Thank you

How to alter table with computed column

$
0
0

I have a table with computed column

CREATE TABLE XXXX(
[DATE_VAL] [varchar](50) NULL,
[DATE] AS (case when isdate([DATE_VAL])=(1) then CONVERT([datetime],[DATE_VAL])
when isdate('20'+substring([DATE_VAL],(3),len([DATE_VAL])-(2)))=(1) then CONVERT([datetime],'20'+substring([DATE_VAL],(3),len([DATE_VAL])-(2)))  end)


i need to alter the computed column by removing the second case expression
do i need to drop the computed column and recreate or can i alter the same computed column
[DATE]  AS (case when isdate([DATE_VAL])=(1) then CONVERT([datetime],[DATE_VAL])

Server Exception when using JDBC to Connect with SAP

$
0
0

Hello,

I am trying to connect to a view in an external database using JDBC. When I run the TestJDBC Tool, I get the following server exception:

com.microsoft.sqlserver.jdbc.SQLServerException: ?? ?? '<view_name>'?(?) ???????.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
    at com.sap.ip.bi.sdk.trialarea.connector.servlet.model.JDBCModel.getColumns(JDBCModel.java:202)
    at com.sap.ip.bi.sdk.trialarea.connector.servlet.controller.Control3.doPost(Control3.java:25)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
    at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
    at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
    at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
    at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
    at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
    at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)

The question marks really make it difficult to determine exactly what the issue is.

Is there a way to perform a trace or to determine what is going on? Our third party provider has already confirmed that the authorization they provided is correct and is working.

Thanks!

ADO inserting extra T-SQL text

$
0
0

According to the documentation for the Execute Method of the ADO Connection Object: 

CommandText

String value that contains the SQL statement, stored procedure, a URL, or provider-specific text to execute. Optionally, table names can be used but only if the provider is SQL aware. For example if a table name of "Customers" is used, ADO will automatically prepend the standard SQL Select syntax to form and pass "SELECT * FROM Customers" as a Transact-SQL statement to the provider.

Now when I invoke a stored procedure in the text as "EXECUTE usp_MyStoredProc @Param1  = " & someVal (this is classic ASP), I get an error on occasion that makes no sense in relation to the text.  Upon reviewing the submitted SQL in the SQL Server Profiler I see "select * from EXECUTE usp_MyStoredProc @Param1  =  0" (for example from the above).  So why does ADO arbitrarily prepend the extra command portion in this instance?  Can I turn this off? I am using the SQL Server Native Client provider and I am randomly seeing this on my SQL Server 2005, 2008 and 20012 instances.  No rhyme or reason as to when it decides to this.

Your insight is most welcome on this issue.


Make SQL record unavailable when in use

$
0
0

Hi Guys

I have a system that has multiple users and on one page (PageList) it shows a list of records and when a user selects it another page (PageDetails) with the details opens up. More like a call center scenario

eg. When UserA is viewing PageDetails of Record1 and UserB opens PageList Record1 is not available or shows that its being used.

How can I got about doing this, making sure a record being accessed is not accessed by another user

Thank in advance.

Viewing all 4164 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>