Questions tagged [sql-server-2000]

Use this tag for questions specific to the 2000 version of Microsoft's SQL Server. Note that as of April 9, 2013, Microsoft no longer supports this version of SQL Server, to the point that even security patches are no longer created.

SQL Server 2000 (codename Shiloh, version 8.0), released in September 2000, is the successor to SQL Server 7.0.

2591 questions
68
votes
2 answers

How can I insert binary file data into a binary SQL field using a simple insert statement?

I have a SQL Server 2000 with a table containing an image column. How do I insert the binary data of a file into that column by specifying the path of the file? CREATE TABLE Files ( FileId int, FileData image )
scottm
  • 26,493
  • 22
  • 102
  • 155
67
votes
6 answers

Get the time of a datetime using T-SQL?

How to get the time for a given datetime value? I have a datetime in database like this: 2010-09-06 17:07:28.170 and want only the time portion: 17:07:28.170 Is there a function for that or something?
grady
  • 11,053
  • 26
  • 67
  • 107
66
votes
7 answers

SQL Server 2000: How to exit a stored procedure?

How can I exit in the middle of a stored procedure? I have a stored procedure where I want to bail out early (while trying to debug it). I've tried calling RETURN and RAISERROR, and the sp keeps on running: CREATE PROCEDURE dbo.Archive_Session…
Ian Boyd
  • 220,884
  • 228
  • 805
  • 1,125
65
votes
5 answers

Is there a way to get a list of all current temporary tables in SQL Server?

I realize that temporary tables are session/connection bound and not visible or accessible out of the session/connection. I have a long running stored procedure that creates temporary tables at various stages. Is there a way I can see the list of…
AAsk
  • 1,335
  • 4
  • 16
  • 23
63
votes
6 answers

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

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…
Wai Wong
  • 2,081
  • 3
  • 17
  • 17
63
votes
3 answers

How to fix the embedded text qualifier issue while exporting data to CSV flat file?

RFC 4180: RFC 4180 defines Common Format and MIME Type for Comma-Separated Values (CSV) Files. One of the requirements of the RFC 4180 is stated as below. This is the point #7 in the RFC link. If double-quotes are used to enclose fields, then a…
user756519
63
votes
5 answers

SQL where datetime column equals today's date?

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…
Beginner
  • 25,463
  • 62
  • 148
  • 228
61
votes
8 answers

ORDER BY DATE showing NULLS first then most recent dates

I have a stored procedure which executes a select statement. I would like my results ordered by a date field and display all records with NULL dates first and then the most recent dates. The statement looks like this: SELECT a,b,c,[Submission…
Eppz
  • 3,018
  • 2
  • 17
  • 26
54
votes
7 answers

How to output a boolean in T-SQL based on the content of a column?

I made a view to abstract columns of different tables and pre-filter and pre-sort them. There is one column whose content I don't care about but I need to know whether the content is null or not. So my view should pass an alias as "true" in case the…
Anheledir
  • 4,292
  • 7
  • 30
  • 34
47
votes
8 answers

SQL get the last date time record

I'm trying to get the last datetime record from a table that happens to store multiple status. My table looks like so: +---------+------------------------+-------+ |filename |Dates |Status…
Miguel
  • 1,050
  • 1
  • 15
  • 25
46
votes
4 answers

How do I select a 1 as a bit in a sql-server view?

I want to create a view in which I select something like the following: select id, name, 1 as active from users However, I want the active field, which I am creating in the select statement (it doesn't exist in the table), to be a bit field. Is…
dmr
  • 19,157
  • 34
  • 91
  • 136
45
votes
4 answers

MSSQL Select statement with incremental integer column... not from a table

I need, if possible, a t-sql query that, returning the values from an arbitrary table, also returns a incremental integer column with value = 1 for the first row, 2 for the second, and so on. This column does not actually resides in any table, and…
Rodrigo
  • 4,162
  • 3
  • 29
  • 47
42
votes
3 answers

INSERT INTO @TABLE EXEC @query with SQL Server 2000

Is it true that SQL Server 2000, you can not insert into a table variable using exec? I tried this script and got an error message EXECUTE cannot be used as a source when inserting into a table variable. declare @tmp TABLE (code varchar(50), mount…
XMozart
  • 659
  • 1
  • 8
  • 19
40
votes
4 answers

Select column, if blank select from another

How does one detect whether a field is blank (not null) and then select another field if it is? What I really need is a IsBlank function that works the same as IsNull but with with blanks. REPLACE doesn't work with blanks, COALESCE only works with…
graham.reeds
  • 15,267
  • 16
  • 66
  • 133
37
votes
2 answers

What exactly does the T-SQL "LineNo" reserved word do?

I was writing a query against a table today on a SQL Server 2000 box, and while writing the query in Query Analyzer, to my surprise I noticed the word LineNo was converted to blue text. It appears to be a reserved word according to MSDN…