sql-server-2000

How can i find the particular days

半世苍凉 提交于 2019-12-08 04:21:43
问题 I have the date value like this - 12/2011 or 11/2011 ( MM/yyyy ) I want to find the sundays on the particular month.... For Example, If i select the month 01/2012, The query should give the result like this 01 08 15 22 29 The above date are sunday. Expected Output for 01/2012 Month 01 08 15 22 29 How to make a query Need Query Help 回答1: With a little help of a number table ( master..spt_values ) declare @M varchar(7) set @M = '01/2012' declare @D datetime set @D = convert(datetime, '01/'+@M,

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

早过忘川 提交于 2019-12-08 03:08:03
问题 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

Rotate/pivot 1000 columns to rows

随声附和 提交于 2019-12-08 02:41:34
问题 I inherited a DB from which I need to extract data in columns that is currently arranged in rows. The query to retrieve the data is: select distinct LIMSNo, p250.*, p500.*, p750.*, p1000.* from results as r inner join Points250 as p250 on r.resultsid = p250.resultsid and p250.channel = 1 inner join Points500 as p500 on r.resultsid = p500.resultsid and p500.channel = 1 inner join Points750 as p750 on r.resultsid = p750.resultsid and p750.channel = 1 inner join Points1000 as p1000 on r

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

孤者浪人 提交于 2019-12-08 02:17:08
问题 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

SQL Group by with concat

妖精的绣舞 提交于 2019-12-08 01:01:48
问题 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 回答1: You can create a

Convert SQL Server Database from 2005 to 2000

北慕城南 提交于 2019-12-07 18:48:17
问题 We have a Microsoft SQL Server 2005 database that needs to be converted back to SQL Server 2000. Does anybody have any suggestions on the approach or tools I should use to perform this conversion? We don't utilise any SQL Server 2005 specific features in the database so this should not make the conversion problematic. I should mention that I have found the Microsoft SQL Server Export facility very buggy in dealing with Auto Generated Keys so suggestions for alternative tools would be

How to run a Job from a Stored Procedure in another server?

纵饮孤独 提交于 2019-12-07 18:04:46
问题 Is it possible to run a Job from a stored procedure located in a different server? If so, how? 回答1: So why not consider using exec LINKEDSERVERNAME.msdb.dbo.sp_start_job 'Job Name' ? (didn't test it though, maybe some-unseen-answer was the same, but erased as incorrect and not working) There must be enough privileges for linked-server-login to run the job, of course - at least it has to be job's owner. 回答2: Yep, you can use the evil that is osql: osql -S "Remote Server" -E -Q"exec msdb.dbo.sp

The multi-part identifier could not be bound again

寵の児 提交于 2019-12-07 12:44:19
问题 I am trying to create a stored procedure like this, CREATE PROCEDURE [dbo].[SP_Name] ( @ID varchar(50), @URL varchar(256) ) AS SELECT DISTINCT Table1.CID, Table2.Name, Table2.aID, Table2.bID, Table3.SchemeName, Table2.cURL FROM Table4 INNER JOIN Table5 ON Table5.eID = Table1.eID INNER JOIN Table2 ON Table2.ID = Table1.CID INNER JOIN [Table3] ON Table3.aID = Table2.aID AND Table3.bID = Table2.bID WHERE Table5.ID = @ID AND Table2.cURL LIKE '%' + @URL + '%' but I'm getting this error: Msg 4104,

Crosstab Query in SQL Server 2000

我的未来我决定 提交于 2019-12-07 12:27:12
问题 I am hoping that someone has attempted this before and I can get some advice before I go any further. I am looking to produce something similar to a crosstab query in sql-server 2000. I have a table structure similar to the following: Item Item_Parameter Parameter id item_id id desc parameter_id desc value What I am looking to do is to flatten out the data through a query/stored procedure to make building reports easier. The ideal solution would produce results such as: Parameter.desc[0]

SQL Server: Must numbers all be specified with latin numeral digits?

假如想象 提交于 2019-12-07 11:23:56
问题 Does SQL server expect numbers to be specified with digits from the latin alphabet, e.g.: 0123456789 Is it valid to give SQL Server digits in other alphabets? Rosetta Stone: Latin: 01234567890 Arabic: ٠١٢٣٤٥٦٧٨٩ Bengali: ০১২৩৪৫৬৭৮৯ i know that the client (ADO) will convert 8-bit strings to 16-bit unicode strings using the current culture. But the client is also converting numbers to strings using their current culture, e.g.: SELECT * FROM Inventory WHERE Quantity > ২৩৪,৭৮ Which throws SQL