sql-server-2000

Cursorfetch:The number of variables declared in the INTO list must match that of selected columns

倾然丶 夕夏残阳落幕 提交于 2020-07-18 21:08:27
问题 declare @id int declare @empid int set @id = 0 declare @schedindate datetime declare @ss nvarchar(100) declare @indice nvarchar(2) declare @FromDate datetime declare @ToDate datetime declare @TimeInR datetime declare @TimeOutR datetime set @FromDate = '2009-01-14' set @ToDate = '2010-01-30' Declare cc cursor for select distinct empid from ta_timecard where schedindate between @FromDate and @ToDate open cc fetch next from cc into @empid while (@@fetch_status = 0) begin set @id = @id + 1 insert

How do I disable errors on string truncation in SQL Server?

北慕城南 提交于 2020-06-22 11:12:08
问题 How can I tell SQL Server not to raise an error if I insert or update a string longer than the size of the field - I would like silent truncation in this instance. 回答1: The thing you have to do is set ANSI WARNINGS to OFF You can do that by calling set ANSI_WARNINGS OFF I have also written a practical example: create table bla(id varchar(2)) go insert bla values ('123') --fails set ANSI_WARNINGS OFF insert bla values ('123') --succeeds Do remember to turn the ANSI warnings back ON when you

sql server round function not working well

时光总嘲笑我的痴心妄想 提交于 2020-04-30 07:41:59
问题 I am using sql server 2000 and facing round function issue like the following statement working fine. SELECT ROUND(5 * 7.83, 1) The result will be 39.2 But when I get these values from the table, it gives 39.1, meaning it truncates and does not round up. SELECT ROUND(rate * qty, 1) FROM tbl The result will be 39.1 rate and qty columns data types are float. Insert 5 in qty and 7.83 in rate , then check it. How I can fix it? 回答1: Convert the table values to real, SELECT ROUND(convert(real,rate)

sql server round function not working well

情到浓时终转凉″ 提交于 2020-04-30 07:41:22
问题 I am using sql server 2000 and facing round function issue like the following statement working fine. SELECT ROUND(5 * 7.83, 1) The result will be 39.2 But when I get these values from the table, it gives 39.1, meaning it truncates and does not round up. SELECT ROUND(rate * qty, 1) FROM tbl The result will be 39.1 rate and qty columns data types are float. Insert 5 in qty and 7.83 in rate , then check it. How I can fix it? 回答1: Convert the table values to real, SELECT ROUND(convert(real,rate)

Get structure of temp table (like generate sql script) and clear temp table for current instance

大兔子大兔子 提交于 2020-04-07 11:10:26
问题 How do I get structure of temp table then delete temp table. Is there a sp_helptext for temp tables? Finally is it possible to then delete temp table in same session or query window? Example: select * into #myTempTable -- creates a new temp table from tMyTable -- some table in your database tempdb..sp_help #myTempTable Reference. 回答1: You need to use quotes around the temp table name and you can delete the temp table directly after using drop table ... . select * into #myTempTable -- creates

How to Obtain Domain User Name when connecting via SQL Authentication

拥有回忆 提交于 2020-02-04 05:41:09
问题 I have an application which connects to SQL Server 2000 (using a generic SQL Login and SQL Authentication). I would like to implement some logging via triggers to track data changes. I can't use USER_NAME() because that returns the generic account. I've poked through master..sysprocesses and it doesn't seem to record the username (although it does record the machine name). Any ideas how, within SQL, to gain access to the username? (Note: yes, I could pass it in as a variable via the

How to make total?

给你一囗甜甜゛ 提交于 2020-01-25 12:51:06
问题 Using SQLSERVER 2000 How to make a total of intime value Table 1 InTime 02:00:48 22:00:22 ....., Intime Datatype is varchar 02:00:12 - (HH:MM:SS) Before I tried in access 2003 select format( Int(24*sum(Intime)), '0') & format( sum(Intime) , ':ss' ) AS totaltime from table1 Above Query is working perfectly in Access 2003 How to make a total of Intime in sql? Expected Output Intime 24:01:00 So on..., Need Query help 回答1: try this: CREATE TABLE #Table1 ( inTime varchar(8) ) SET NOCOUNT ON INSERT

How to make total?

孤者浪人 提交于 2020-01-25 12:50:09
问题 Using SQLSERVER 2000 How to make a total of intime value Table 1 InTime 02:00:48 22:00:22 ....., Intime Datatype is varchar 02:00:12 - (HH:MM:SS) Before I tried in access 2003 select format( Int(24*sum(Intime)), '0') & format( sum(Intime) , ':ss' ) AS totaltime from table1 Above Query is working perfectly in Access 2003 How to make a total of Intime in sql? Expected Output Intime 24:01:00 So on..., Need Query help 回答1: try this: CREATE TABLE #Table1 ( inTime varchar(8) ) SET NOCOUNT ON INSERT