Ive got a table of notes people have created, with a field called "timecreated" which has a default value of "GETDATE()" Im trying to write an SQL statement that will count up all of the notes that people have created today/ yesturday etc. i could do it if the timecreated value was a "short date string" styled date, but its set up like : 11/11/2007 18:51:46 is there way of converting it before counting? if theres a simple way of doing this i would appricate any help thanks John
I would like to AUTOMATICALLY count the event for the month BEFORE today
and
count the events remaining in the month (including those for today).
I can count the events remaining in the month manually with this query (today being March 20):
SELECT Count(EventID) AS [Left for Month], FROM RECalendar WHERE (EventTimeBegin >= DATEADD(DAY, 1, (CONVERT(char(10), GETDATE(), 101))) AND EventTimeBegin < DATEADD(DAY, 12, (CONVERT(char(10), GETDATE(), 101))))
Could anyone provide me with the correct syntax to count the events for the current month before today
and
to count the events remaining in the month, including today.
First latest Identity column is 5 I try to insert value to table which have Identity column by ExecuteNonQuery() method. There was some error and rollback this transaction.and then I modified code for completely saving after that I try to insert value again by running program although this transaction completely But value in identity is 7 ( It seems value 6 didn't rollback when not completely saveing ) Please advise me How can I rollback Identity column value ?
I have a transaction log that is 80% full and will not dump. I have used the "dump transaction dbname with no_log" command. It return the usual "This command did not return data, and it did not return any rows". However, this didn't do anything. The transaction log is still full. I don't want to restart the server if I don't have to. Any ideas?
We have Active/Passive cluster on Windows 2003. It is a 2 nodes cluster. The active server came down and the Cluster didn't failover. Then we had to manually failover. Can you help me to decipher the Cluster.log to find out why it didn't failover?
00000d08.000012a8::2007/10/12-04:04:40.847 ERR SQL Server <SQL Server>: [sqsrvres] CheckQueryProcessorAlive: sqlexecdirect failed 00000d08.000012a8::2007/10/12-04:04:40.847 ERR SQL Server <SQL Server>: [sqsrvres] printODBCError: sqlstate = HYT00; native error = 0; message = [Microsoft][SQL Native Client]Query timeout expired 00000d08.000012a8::2007/10/12-04:04:40.847 ERR SQL Server <SQL Server>: [sqsrvres] OnlineThread: QP is not online. 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [CP] CppRegNotifyThread checkpointing key SoftwareMicrosoftMicrosoft SQL ServerMSSQL.1MSSQLSERVER to id 4 due to timer 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsGetTempFileName C:DOCUME~1SVC_CL~1LOCALS~1Temp, CLS, 13522 => C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D2.tmp, status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D2.tmp, status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsRegSaveKey C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D2.tmp, status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [CP] CpSaveData: checkpointing data id 4 to quorum node 1 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [CP] CppWriteCheckpoint checkpointing file C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D2.tmp to file Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsCreateDirectory Q:MSCS 592a048-5457-426a-a46d-996441ef0182, status 183 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsOpenFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D2.tmp => 3, 36cf960 status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsOpenFile Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT => 2, 36cf8d0 status 183 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] ReadFile 928 (regf) 32768 16384, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] WriteFile 95c (regf) 16384, status 0 (0=>0) 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] ReadFile 928 (regf) 32768 0, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsFlushBuffers 95c, status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsCloseHandle 928, status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsCloseHandle 95c, status 0 0000077c.000003dc::2007/10/12-04:04:43.785 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D2.tmp, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [CP] CppRegNotifyThread checkpointing key SoftwareMicrosoftMicrosoft SQL ServerMSSQL.1MSSQLSERVER to id 4 due to timer 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsGetTempFileName C:DOCUME~1SVC_CL~1LOCALS~1Temp, CLS, 13523 => C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D3.tmp, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D3.tmp, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsRegSaveKey C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D3.tmp, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [CP] CpSaveData: checkpointing data id 4 to quorum node 1 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [CP] CppWriteCheckpoint checkpointing file C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D3.tmp to file Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsCreateDirectory Q:MSCS 592a048-5457-426a-a46d-996441ef0182, status 183 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsOpenFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D3.tmp => 3, 36cf960 status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsOpenFile Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT => 2, 36cf8d0 status 183 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] ReadFile 95c (regf) 32768 16384, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] WriteFile 928 (regf) 16384, status 0 (0=>0) 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] ReadFile 95c (regf) 32768 0, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsFlushBuffers 928, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsCloseHandle 95c, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsCloseHandle 928, status 0 0000077c.000003dc::2007/10/12-04:06:23.084 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D3.tmp, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [CP] CppRegNotifyThread checkpointing key SoftwareMicrosoftMicrosoft SQL ServerMSSQL.1MSSQLSERVER to id 4 due to timer 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsGetTempFileName C:DOCUME~1SVC_CL~1LOCALS~1Temp, CLS, 13524 => C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D4.tmp, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D4.tmp, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsRegSaveKey C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D4.tmp, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [CP] CpSaveData: checkpointing data id 4 to quorum node 1 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [CP] CppWriteCheckpoint checkpointing file C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D4.tmp to file Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsCreateDirectory Q:MSCS 592a048-5457-426a-a46d-996441ef0182, status 183 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsOpenFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D4.tmp => 3, 36cf960 status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsOpenFile Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT => 2, 36cf8d0 status 183 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] ReadFile 7e0 (regf) 32768 16384, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] WriteFile 95c (regf) 16384, status 0 (0=>0) 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] ReadFile 7e0 (regf) 32768 0, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsFlushBuffers 95c, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsCloseHandle 7e0, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsCloseHandle 95c, status 0 0000077c.000003dc::2007/10/12-04:08:08.259 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D4.tmp, status 0 0000077c.00000844::2007/10/12-04:09:11.323 INFO [Qfs] GetDiskFreeSpaceEx Q:MSCS, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [CP] CppRegNotifyThread checkpointing key SoftwareMicrosoftMicrosoft SQL ServerMSSQL.1MSSQLSERVER to id 4 due to timer 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsGetTempFileName C:DOCUME~1SVC_CL~1LOCALS~1Temp, CLS, 13525 => C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D5.tmp, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D5.tmp, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsRegSaveKey C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D5.tmp, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [CP] CpSaveData: checkpointing data id 4 to quorum node 1 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [CP] CppWriteCheckpoint checkpointing file C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D5.tmp to file Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsCreateDirectory Q:MSCS 592a048-5457-426a-a46d-996441ef0182, status 183 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsOpenFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D5.tmp => 3, 36cf960 status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsOpenFile Q:MSCS 592a048-5457-426a-a46d-996441ef0182 0000004.CPT => 2, 36cf8d0 status 183 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] ReadFile 928 (regf) 32768 16384, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] WriteFile 7e0 (regf) 16384, status 0 (0=>0) 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] ReadFile 928 (regf) 32768 0, (0=>0) 0 status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsFlushBuffers 7e0, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsCloseHandle 928, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsCloseHandle 7e0, status 0 0000077c.000003dc::2007/10/12-04:09:56.652 INFO [Qfs] QfsDeleteFile C:DOCUME~1SVC_CL~1LOCALS~1TempCLS34D5.tmp, status
i made an application using vb6 that access the table in a sqlserver database and in the load event i write cn.mode=adsharedenyread
and i make two copies of the application and run them both of them read the data and no deny happen !!! although both of the applications have adsharedenyread
how can i make privilage for some users to read or write ? by the way is that can be done in ado.net 2.0 ?
I am writting a T-SQL script to install my database. I have figured out all the sets except 2 areas.
1. Give login db_datareader / db_datawriter permissions to a DB 2. Add a DTS Package, it uses a script, and schedule it.
Here's how I do them in EM....
Issue 1: Security - Logins, Right click on login, select properties In database access tab, check Permit for DB In database role, check public, db_datareader, db_datawriter.
Issue 2: DTS - Local Packages Right click on local package, new package. Create SQL connection & exe SQL task (attach seperate SQL script) Save Right click on newly created package and schedule
--create a temp table like: select * into #tmp from (select 1 as ID union all select 2 union all select 3 union all select 4 ) as A
-then run this query: select B.ID,isNull(B.GID,0) as GID from (select #tmp.ID,A.GID from #tmp left outer join (select ID,1 as GID from #tmp where ID in (2,4)) A on #tmp.ID = A.ID ) as B
--I thougth it should return: 10 21 30 41 --but it actually returned: IDGID 11 21 31 41 --if I change GID value in '...(select ID,1 as GID from #tmp where ID in (2,4)...', for example 2, then it return: IDGID 12 22 32 42
I have just done my first clean install of SQL 2005. I have previously upgraded several boxes from SQL 2000 without incident.
The clean install seemed to go fine but the Maintenance Tasks didn't install? I have looked on the web but have been unable to unearth any information. Has anyone encountered this before and if so I how do I add Maintenance Tasks to the Management folder?
Hi every body ! I try to insert the reportViewer in my asp page, all is good, but if I want to change (by choosing another report), and i cannot call the method RefreshReport() as I saw in the msdn documentation. I didn't understand why, I download the ReportViewer from msdn download : the version is 2.0.50727.42 from 22/01/2006... I implement in my asp designer tools the following dll : Microsoft.SqlServer.UpgradeAdvisor.ReportViewer.dll 9.0.1399.1 from 14/10/2005
Did I forget any code line ? or did I download a bad version ?
I created a SSIS package that imports a file then moves the file to a folder called processed. I created a job that runs the package. The pack works fine when I run it from the SQL Storage Area. When I run the job I get the following message:
Started: 9:58:15 AM DTExec: The package execution returned DTSER_SUCCESS (0). Started: 9:58:15 AM Finished: 9:58:21 AM Elapsed: 6.047 seconds. The package executed successfully. The step succeeded.
showing that the job supposedly completed successfully.
I know that the package the not run because the data did not get imported and the file did not move.
Can anyone explain the package may not run but we still get a job completion status of success?
Hello everybody , I want you to explain me something that i find a little strange. Yesterday i had a problem with a huge log file and a friend in here helped me fix this by making a log back up and then shrinking it to 200 MB.Everything went fine.When i returned home i tried something else in a test environment..Here what happened: I Got a full database back up. I dropped the database. I created a new one with 1GB mdf and 250MB ldf. I vanished the log back -up I restored the mdf file on the new database The log file again had the same huge size after the restore. How did this happen?
I have 1 table: ID pagename datevisited 1default01/01/2006 1info01/01/2006 1default02/01/2006 1info02/01/2006 1summary02/01/2006 2default02/01/2006 2info02/01/2006 2summary02/01/2006
I need to run query for ID who didn't visited a summary page(per day) How do I do this?
I have a backup plan that remove the old backup files more than two days. Last Monday, the SQL Server restart. Since that, the backup is fine, but it didn't remove the old backup files. Why and how to handle that? Thanks
I ran a SQL statement to get the data from two tables using join. These two tables have a column in the same name €śID€?.
SQL=€?select * from table1 a, table2 b where a.ID=b.ID€? Set RS=DB.Execute(SQL)
The statement worked. But when I output the records in my ASP pages, I got an error: ADODB.Recordset error '800a0cc1' Item cannot be found in the collection corresponding to the requested name or ordinal€?
This is the line caused error: <%= RS(€śa.ID€?) %>
It seemed that SQL Server recordset doesn€™t carry the table aliens. If I removed a. from ID the error was gone but it gave me the value of b.ID.
my problem is i create a user in sqlserver from enterprise manager as follows:-
1- goto logins and new login 2-type a name and choose sqlserver authentication and type a password 3- from server roles tab i choose system administrators 4 from database access i choose the database i need that user to connect to .and OK 5-i goto database node in enterprise manager and select the database and the table and double click on it and choose permissions and de-select the SELECT privilige
then i use ADO to connect to sqlserver through that user and when i select(SQL query) the table the data appeared normally !!!! and it suppose to give me exception
Dear all, I have built an SSIS package by using the BI Dev Studio and enabled its configuration xml file. The package have a variable called TranDate and I want to put it dynamically from a Calendar on my website (just like assigning a variable). I have successfully change the value of that variable in the configuration files (affected to the xml file). Then I loaded the package and executed it (through my web). It's still get the old value (which I have assigned while creating the package). I didn't understand that where else can the package get the value of that variable so it still get the old value (that value have never appeared in the xml configuration file anymore when I changed it).
Thanks for reading this, and I am looking forward to seeing any helps from you guys.
Dear all, I've been searching the article for error handling in SSIS but seems no article have same problem exactly as mine. In my package there's container, it contains Data Flow task and some of Script tasks. I put an error precedence from Data Flow task into Script task that contains script for log an error that might be occured. The Data Flow task imports data from flat file into SQL Server 2005 and I've set a semicolon as the column delimiter. Unfortunately there is a data in flat file that had one column contain semicolon as its value. This would trigger an error and I hope the error would be logged into a table as I wrote inside Script task. But it didn't work. The error precedence won't work, the package stop in flat file source instead. I've been trying the event handler but it didn't work either. Maybe I got wrong implementation, anybody can help me explain the error handler and solve the problem ? Here is the capture of my package, since I didn't know how to attach the picture in this forum. Thanks in advance.
One interviewer has asked me the following question: What are the things that you consider while designing database? I have told about integrity constraints, and normal forms. but he has added 15 more concepts like 1. indexers 2. Table columns 3. Table rows 4. search facilities 6....... Can any one give full Idea on this question? Thanking you Ashok kumar.
SQL 2000I have inherited an application where many of the automated processescall a proc that simply returns the number of records with a NEWstatus.In watching the process in SQL, I see this ends up blocking a lot ofprocesses - many like this are called every 5-30 seconds ...I wish to replace COUNT(*) with EXISTS if that will make things operatefaster with no locks ...Thoughts ...Thanks everyone !!Craig
I have made a report in SRS and am not sure of how to do some of the functions I need.
In SQL I can use UPPER to convert to upper case, SRS doesn't seem to like this. The report runs but the line that is to be upper case is missing. If I remove the UPPER word from my query it works fine just displaying in lower case. Am I doing something wrong?
In Excel 2007 (I am converting my report from Excel to SRS) there is a function called NETWORKDAYS (Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term.) Is there something similar I can use in SRS?
I'm creating a small application for my local school district that will allow them to do a small management of inventory.
Is there a way to create an executable script that will create the default databases the first time? If so, what all do I need to do for the script and to make it execute? I want to make a section in my OPTIONS area where users can put the path to their db (will not be hosted on the same PC as the software) along with the username and password for the db. I know I can store this information in a predetermined variable in the program so that it can reference it off and on.
Could someone please help me with this..... If it's in the wrong forum please let me know.
I am a newbe in this and I tried to find the information on the msdn but could not find a god answer.
I am using VisualStudio Express 2005 and a SQL Server Express version.
In a Visual Basic application I use "radio buttons", "tick boxes", "Combo Boxes" and "Numeric Up Down".
But I cant figure out what data type to use to save the data in a SQL server.
It would be nice to have a document that maps the different data types to use in SQL Server according to what object you are using in the Visual Studio.
I've here a shell plugin and it's compiling fine and can be viewed in BI Dev Studio when choosing the DM technique using the proper wizard.
I also have here a K-Means implementation that estimates the number of clusters using a statistical semi-empiric index (the PBM index).
This implementation is done in C# and works fine. But it has to receive all the data of the database (all variables for each row) in order to do the proper vectorial calculations in a CSR (Compact Sparse Rows) way.
Besides, as you know, K-Means needs all the data at once because of the clusters mean (centroid) calculation.
So, I have some questions:
1) Where to place the call to the K-Means implementation in the shell passing as argument an object holding all the data ?
2) After this call, with the data clustered, what other objects must be modified in order to use Microsoft Cluster Viewer ?
3) I will need to create a new column or a new table on the database to specify which data belongs to which cluster. Can I open an ADO connection as I normally do in other programs from inside the plugin or is there another (easier/better) way to do so ?
I've got a .dtproj project along with 10 dtsx packages. Up to here everything is fine, every package have its own source files, sql destinations and so on.. Issue comes when I try create a flat file source connection for the eleven one.
I get this message:
The component has detected potential metadata corruption during validation. Error at Data Flow Task [Flat File Source [1]]: Failed to find any non-special error column in output "Flat File Source Error Output" (3).
It may not be possible to recover to a valid state using a component-specific editor. Do you want to use the Advanced Editor dialog box for editing this component?
Otherwise if I'm gonna to open a new .dtproj project separately no problem at all, I mean, appears the suitable window, "Connection Manager", "Column", "Error output" on the left and so on..
It's very strange. The rest of the packages, the same situation. Fortunately, all of them are stored on the server.
I don't get the point at all. Could you please tell me what the hell is happening?
I am doing search through Date Range but didn't get correct result.
For Example if i created a Task on 5/8/2014 and when i have take Date Range from 1/8/2014 to 6/8/2014 then didn't get 5/8/2014 data in result but when i taken range from 1/8/2014 to 5/8/2014 then got the 5th Date data.