sql-server-2000

SQL where datetime column equals today's date?

女生的网名这么多〃 提交于 2019-12-03 04:43:37
问题 How can I get the records from a db where created date is today's date? SELECT [Title], [Firstname], [Surname], [Company_name], [Interest] FROM [dbo].[EXTRANET_users] WHERE DATE(Submission_date) = DATE(NOW()) This doesn't work im using sql server 2000 and submission date is a date time field 回答1: Looks like you're using SQL Server, in which case GETDATE() or current_timestamp may help you. But you will have to ensure that the format of the date with which you are comparing the system dates

select a value where it doesn't exist in another table

南笙酒味 提交于 2019-12-03 04:10:18
I have two tables Table A: ID 1 2 3 4 Table B: ID 1 2 3 I have two requests: I want to select all rows in table A that table B doesn't have, which in this case is row 4. I want to delete all rows that table B doesn't have. I am using SQL Server 2000. You could use NOT IN : SELECT A.* FROM A WHERE ID NOT IN(SELECT ID FROM B) However, meanwhile i prefer NOT EXISTS : SELECT A.* FROM A WHERE NOT EXISTS(SELECT 1 FROM B WHERE B.ID=A.ID) There are other options as well, this article explains all advantages and disadvantages very well: Should I use NOT IN, OUTER APPLY, LEFT OUTER JOIN, EXCEPT, or NOT

Is there a way to list open transactions on SQL Server 2000 database?

做~自己de王妃 提交于 2019-12-03 02:53:42
问题 Does anyone know of any way to list open transactions on SQL Server 2000 database? I am aware that I can query the view sys.dm_tran_session_transactions on SQL 2005 (and later) database versions, however this is not available on SQL 2000. 回答1: For all databases query sys.sysprocesses SELECT * FROM sys.sysprocesses WHERE open_tran = 1 For the current database use: DBCC OPENTRAN 回答2: You can get all the information of active transaction by the help of below query SELECT trans.session_id AS

How do I join the first row of a subquery?

做~自己de王妃 提交于 2019-12-02 23:50:16
I've got a table of invoices and a child table of related data related by key. In particular, for each invoice, I'm interested in only the first related row from the child table. Given that I want the one related row for every invoice key - how do I accomplish this? Select i.[Invoice Number], c.[Carrier Name] From Invoice i Left Join Carriers c on i.[InvoiceKey] = c.[InvoiceKey] Where -- what? I guess semantically speaking, what I'm looking for something akin to the concept of Top 1 c.CarrierName Group by InvoiceKey (or what would be the concept of that if that were possible in T-SQL.) I've

Start stored procedures sequentially or in parallel

若如初见. 提交于 2019-12-02 21:02:15
We have a stored procedure that runs nightly that in turn kicks off a number of other procedures. Some of those procedures could logically be run in parallel with some of the others. How can I indicate to SQL Server whether a procedure should be run in parallel or serial — ie: kicked off of asynchronously or blocking? What would be the implications of running them in parallel, keeping in mind that I've already determined that the processes won't be competing for table access or locks- just total disk io and memory. For the most part they don't even use the same tables. Does it matter if some

T-SQL List Tables, Columns

ぐ巨炮叔叔 提交于 2019-12-02 20:28:29
In T-SQL (SQL Server 2000). How can I list all tables and columns in a database? Also, in a separate query is there a way to list all columns along with data type and constraints (NULLS, etc). Thanks. Please check out the information schema . select * from MyDatabaseName.information_schema.columns order by table_name, ordinal_position Many ways to do it. Below are couple of ways that you can list : Option 1: SELECT db_name() as DATABASE_NAME, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX,

How can I count distinct multiple fields without repeating the query?

跟風遠走 提交于 2019-12-02 20:17:29
问题 I have a query with several groupings that returns a count per month. Something like this: SELECT field1, field2, year(someDate), month(someDate), count(*) as myCount FROM myTable WHERE field5 = 'test' GROUP BY field1, field2, year(someDate), month(someDate) The problem is that I want the count to be distinct per day, based on an id field + the date field (without the time). As in, I want to get the distinct count of ids each day, per month. So I want something like this: SELECT field1,

SubSonic3: Method “FirstOrDefault” throws exception with SQL Server 2000

▼魔方 西西 提交于 2019-12-02 20:08:26
问题 I am using SubSonic3 with SQL Server 2000. I have problem with the method "FirstOrDefault" - it always throws an exception = "Line 1: Incorrect syntax near '('." from the SubSonic.Linq dll EDIT (Added code from comment): InventoryDAL = DAL project name (dll) Inventort= Subsonic3 Gnerated classes Name space WHWarehouses = gnerated object Dim WareH = (From Wh In InventoryDAL.Inventort.WHWarehouses.All _ Where Wh.WarehouseID = 1 ).FirstOrDefault 回答1: I don't know SubSonic, but Hibernate has

SQL where datetime column equals today's date?

扶醉桌前 提交于 2019-12-02 19:01:50
How can I get the records from a db where created date is today's date? SELECT [Title], [Firstname], [Surname], [Company_name], [Interest] FROM [dbo].[EXTRANET_users] WHERE DATE(Submission_date) = DATE(NOW()) This doesn't work im using sql server 2000 and submission date is a date time field Looks like you're using SQL Server, in which case GETDATE() or current_timestamp may help you. But you will have to ensure that the format of the date with which you are comparing the system dates matches (timezone, granularity etc.) e.g. where convert(varchar(10), submission_date, 102) = convert(varchar

Is there a “poor man's” alternative to RedGate for scripting out entire database schema? [closed]

夙愿已清 提交于 2019-12-02 18:16:49
I'm in a situation where I would to generate a script for a database that I could run on another server and get a database identical to the original one, but without any of the data. In essence, I want to end up with a big create script that captures the database schema. I am working in an environment that has SQL Server 2000 installed, and I am unable to install the 2005 client tools (in the event that they would help). I can't afford RedGate, but I really would like to have a database with identical schema on another server. Any suggestions? Any simple .exe (no installation required) tools,