sql-server-2000

SQL Server: How to generate object scripts without DMO/SMO?

ぃ、小莉子 提交于 2019-12-06 13:40:14
i want to generate scripts for database objects, e.g. tables views stored procedures functions Since: SQL Server Management Objects (SMO) SQL Distributed Management Objects (SQL-DMO) (depricated) are not installed on a fresh install of: Windows XP Windows Vista Windows 7 nor are they redistributable, they are not an option ( it will run on a customer's machine ). ( EDIT : It looks as if SMO is actually redistributable as of today.) Is there any source code that converts SELECTs from system tables into associated scripts? i'll start us off with the pseudo-code that scripts a stored procedures,

Select query by type wise

北城以北 提交于 2019-12-06 13:29:35
问题 Table1 Code, desc, type id 01 Rajan 1 01 Sajan 1 01 Vijayan 2 01 Suresh 3 01 Caresh 4 01 Sujesh 4 01 vikran 4 02 desk 1 02 card 2 02 villa 2 02 megash 2 02 supan 3 .... I want to view the table by type id wise Expected Output Code type-1 type-2 type-3 type-4 01 Rajan Vijayan suresh caresh 01 Sajan null null Sujan 01 null null null vikran 02 desk card supan null 02 null villa null null 02 null megash null null How to make a query for the above condition Need Query Help 回答1: So first off just

What is a good way to paginate out of SQL 2000 using Start and Length parameters?

北城以北 提交于 2019-12-06 12:13:12
问题 I have been given the task of refactoring an existing stored procedure so that the results are paginated. The SQL server is SQL 2000 so I can't use the ROW_NUMBER method of pagination. The Stored proc is already fairly complex, building chunks of a large sql statement together before doing an sp_executesql and has various sorting options available. The first result out of google seems like a good method but I think the example is wrong in that the 2nd sort needs to be reversed and the case

SQL: how to select common lines of one table on several column

久未见 提交于 2019-12-06 11:54:47
问题 I have a table : create table a (page int, pro int) go insert into a select 1, 2 insert into a select 4, 2 insert into a select 5, 2 insert into a select 9, 2 insert into a select 1, 3 insert into a select 2, 3 insert into a select 3, 3 insert into a select 4, 3 insert into a select 9, 3 insert into a select 1, 4 insert into a select 9, 4 insert into a select 12, 4 insert into a select 1, 5 insert into a select 9, 5 insert into a select 12, 5 insert into a select 13, 5 insert into a select 14

SQL Server, choosing from two TABLEs using IF statement inside WHERE statement depending on the parameter

南楼画角 提交于 2019-12-06 11:05:55
问题 How can I do the following in SQL Server DECLARE @Local nvarchar(20) SET @Local = 'True' SELECT * FROM My_Table WHERE my_ID IN (IF @Local = 'True' SELECT AllIDs FROM ATable ELSE SELECT TeamIDs FROM TeamTable ) 回答1: Go for a union :- SELECT * FROM My_Table WHERE my_id IN ( SELECT AllIDs AS MyIDs FROM ATable WHERE @Local = 'True' UNION SELECT TeamIDs AS MyIDs FROM TeamTable WHERE @Local <> 'True' ) 回答2: SELECT * FROM mytable WHERE my_id IN ( SELECT allids FROM atable WHERE @Local = 'True' )

SQL Server 2000 - Debugging Deadlocks

元气小坏坏 提交于 2019-12-06 10:08:34
问题 I'm looking for suggestions on how to debug and chase down deadlock issues in an SQL Server 2000 database. I've had it recommended to me to use trace flags 1024 and 3605, which I have found give me the following: 1024 - this trace flag returns the type of locks participating in the deadlock and the current command affected. 3605 - this trace flag sends trace output to the error log. The specific stored procedures, tables and indexes still need to be uncovered, so the goal is to use these

How to use a SQL2000 Linked Server to query an Oracle 11G table

こ雲淡風輕ζ 提交于 2019-12-06 09:51:47
Can someone help me construct the SQL that I need to query the Projects_dim table using the Linked Server "idwd"? To test the connection, I ran a sample query using the linked server name. To access the tables on the linked server, I used a four-part naming syntax: linked_server_name.catalog_ name.schema_name.table_name. replacing the values, you get: idwd.idwd.wimr.PROJECTS_DIM of should it be the following? idwd..wimr.PROJECTS_DIM The database name is "idw" but the grid below shows a blank value under "catalog", which is one source of my confusion, though I believe that the more likely

Stored Procedure consist Add column, Update data for that column, and Select all data from that table

梦想的初衷 提交于 2019-12-06 09:19:08
I've written a stored procedure as following: CREATE PROC spSoNguoiThan @SNT int AS begin IF not exists (select column_name from INFORMATION_SCHEMA.columns where table_name = 'NhanVien' and column_name = 'SoNguoiThan') ALTER TABLE NhanVien ADD SoNguoiThan int else begin UPDATE NhanVien SET NhanVien.SoNguoiThan = (SELECT Count(MaNguoiThan)FROM NguoiThan WHERE MaNV=NhanVien.MaNV GROUP BY NhanVien.MaNV) end SELECT * FROM NhanVien WHERE SoNguoiThan>@SNT end GO Then I get the error : Server: Msg 207, Level 16, State 1, Procedure spSoNguoiThan, Line 12 Invalid column name 'SoNguoiThan'. Server: Msg

SQL Group by with concat

五迷三道 提交于 2019-12-06 07:09:43
Hi Can anybody help me with the following. I need to write a MS SQL statment to achive the following: Table1 has 2 columns: Column1 and Column2 Data in table1 looks like Column1 Column2 1 a 1 b 1 c 2 w 2 e 3 x I need my Sql statment to output as following Column1 Column2 1 a, b, c 2 w, e 3 x So in other words I need to group by column1 and have the column2 values concatenate with comma seperated. Please note this will need to be able to run on SQL Server 2000 and above You can create a function to concat the values create function dbo.concatTable1(@column1 int) returns varchar(8000) as begin

Export to excel from SQL Server 2000 using Query Analyzer code

£可爱£侵袭症+ 提交于 2019-12-06 06:54:31
What's the easiest way to export data to excel from SQL Server 2000. I want to do this from commands I can type into query analyzer. I want the column names to appear in row 1. Manual copy and paste is the only way to do exactly what you're asking. Query Analyzer can include the column names when you copy the results, but I think you may have to enable that somewhere in the options first (it's been a while since I used it). Other alternatives are: Write your own script or program to convert a result set into a .CSV or .XLS file Use a DTS package to export to Excel Use bcp.exe (but it doesn't