sql-server-2005

Microsoft SQL Server - Who created a Stored Procedure?

霸气de小男生 提交于 2019-12-20 21:58:49
问题 Is there a good way to tell who created a stored procedure in SQL Server 2005 (that also works in 2008)? In SQL Management Studio I can right mouse/properties on a proc to get the created date/time but how do I discover the creator? 回答1: It may be too late for you now, but you can keep track of DDL activity. We have a table in our administrative database that gets all the activity put in it. It uses a DDL trigger, new to 2005. These scripts create a table in your admin DB (SQL_DBA for me),

PDO datetime format for MSSQL/dblib

北战南征 提交于 2019-12-20 21:58:13
问题 MSSQL 2005 database has collation "German_Phonebook_BIN" (but that's not important). Connection to db is done via PDO and FreeTDS (using PHP under Debian Squeeze). When I try to select datetime values from a table I get results like: Apr 1 2008 12:00:00:000 But I expect to get 2008-01-01 00:00:00 (Regard, that the time 00:00:00 is transformed into 12:00:00, don't know why 00:00=12:00???) There is no way for me to manipulate the SELECT statements (for doing a conversion with CONVERT ). I found

What happen in SQL 2005 when it run out of number for an autonumber column?

泪湿孤枕 提交于 2019-12-20 19:58:43
问题 What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap? What is the behavior of SQL Server 2005 when it happen? 回答1: You will get an overflow error when the maximum value is reached . If you use the bigint datatype with a maximum value of 9,223,372,036,854,775,807 this will most likely never be the case. The error message you will get, will look like this: Msg 220, Level 16, State 2, Line 10 Arithmetic

What happen in SQL 2005 when it run out of number for an autonumber column?

那年仲夏 提交于 2019-12-20 19:58:09
问题 What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap? What is the behavior of SQL Server 2005 when it happen? 回答1: You will get an overflow error when the maximum value is reached . If you use the bigint datatype with a maximum value of 9,223,372,036,854,775,807 this will most likely never be the case. The error message you will get, will look like this: Msg 220, Level 16, State 2, Line 10 Arithmetic

How can we check that table have index or not?

对着背影说爱祢 提交于 2019-12-20 19:41:02
问题 How can we check that table have index or not ? if have how to find that index for a particular column for a table? Regards, kumar 回答1: In SQL Server Management Studio you can navigate down the tree to the table you're interested in and open the indexes node. Double clicking any index in that node will then open the properties dialog which will show which columns are included in the index. If you would like to use T-SQL, this might help: SELECT sys.tables.name, sys.indexes.name, sys.columns

SQL Server 2005 Reporting Services - Pros and Cons

痞子三分冷 提交于 2019-12-20 18:45:49
问题 I am developing a web application using ASP .NET 2.0, VS 2008 and SQL Server 2005. I would like to Use SSRS 2005 for the various reports I need to build for this web application. I would like to convince the team that we should adopt SSRS as the main reporting platform for most internal and external web applications we have. What are the pros and cons of Reporting Services? I can see many pros like tight integration with IIS, SQL Server and Visual Studio, rich presentation features and export

How can I set up a simple calculated field in SQL Server?

好久不见. 提交于 2019-12-20 17:59:49
问题 I have a table with several account fields like this: MAIN_ACCT GROUP_ACCT SUB_ACCT I often need to combine them like this: SELECT MAIN_ACCT+'-'+GROUP_ACCT+'-'+SUB_ACCT FROM ACCOUNT_TABLE I'd like a calculated field that automatically does this, so I can just say: SELECT ACCT_NUMBER FROM ACCOUNT_TABLE What is the best way to do this? I'm using SQL Server 2005. 回答1: ALTER TABLE ACCOUNT_TABLE ADD ACCT_NUMBER AS MAIN_ACCT+'-'+GROUP_ACCT+'-'+SUB_ACCT PERSISTED This will persist a calculated

Count(*) vs Count(Id) in sql server 2005

你。 提交于 2019-12-20 17:32:54
问题 I use SQL COUNT function to get the total number or rows from a table. Is there any difference between the two following statements? SELECT COUNT(*) FROM Table and SELECT COUNT(TableId) FROM Table Also, is there any difference in terms of performance and execution time? 回答1: Thilo nailed the difference precisely... COUNT( column_name ) can return a lower number than COUNT( * ) if column_name can be NULL . However, if I can take a slightly different angle at answering your question, since you

How do check if a parameter is empty or null in Sql Server stored procedure in IF statement?

半腔热情 提交于 2019-12-20 17:32:15
问题 I read this: How do I check if a Sql server string is null or empty but it not helped me in this situation. The piece of code from my stored procedure: IF (@item1 IS NOT NULL) OR (LEN(@item1) > 0) SELECT @sql = 'SELECT * FROM TEST1' ELSE SELECT @sql = 'SELECT * FROM TEST2' PRINT @sql; @item1 is NVARCHAR(1000) type. When execute this stored procedure, I provided the value for item1 EXEC [dbo].[my_proc] @item1 = N'' it shows SELECT * FROM TEST1 // it is correct if @item1 = N'some' instead of

How to pass parameters to Table Valued Function

寵の児 提交于 2019-12-20 16:48:07
问题 I want to do something like select * from tvfHello(@param) where @param in (Select ID from Users) 回答1: You need to use CROSS APPLY to achieve this select f.* from users u cross apply dbo.tvfHello(u.ID) f 回答2: The following works in the AdventureWorks database: CREATE FUNCTION dbo.EmployeeByID(@employeeID int) RETURNS TABLE AS RETURN ( SELECT * FROM HumanResources.Employee WHERE EmployeeID = @employeeID ) GO DECLARE @employeeId int set @employeeId=10 select * from EmployeeById(@employeeId)