sql-server-2005

How to find all foreign keys?

痴心易碎 提交于 2020-01-01 16:48:30
问题 I'd like to find all referencing tables in my db that have a foreign key that points to a specific referenced table. Is there a query that I can run to do this? Not sure if the question is confusing. Let me know if it is and I can try to explain it in more detail. 回答1: The following query or Modification tehreof will do - in Sql server You can also supply catalog and schema info select tab1.TABLE_NAME from INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as ref inner join INFORMATION_SCHEMA.TABLE

Deploying WCF Client assembly in SQL2005

耗尽温柔 提交于 2020-01-01 14:50:09
问题 I'm trying to get a WCF Client assembly deploy in SQL 2005. This means I need to create/register the dependencies for my WCF Client, which are: System.Runtime.Serialization System.Web System.ServiceModel With this script: CREATE ASSEMBLY System_Runtime_Serialization FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll' WITH PERMISSION_SET = UNSAFE GO CREATE ASSEMBLY System_Web FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System

SQL Server Query, running total in view, reset when column A changes

岁酱吖の 提交于 2020-01-01 12:45:11
问题 A colleague of mine has a problem which I am trying to help him with. He has a SQL view which contains the following data (Sample data):- Category Value Cat A 10 Cat A 20 Cat A 30 Cat B 15 Cat B 15 Cat C 10 Cat C 10 He wants to add a column to the view which keeps a running total of the Value column. This column must reset the running total when the Category changes. So the output data must be like this:- Category Value Running Cat A 10 10 Cat A 20 30 Cat A 30 60 Cat B 15 15 Cat B 15 30 Cat C

database email with attachement(excel file / pdf file)?

荒凉一梦 提交于 2020-01-01 11:58:07
问题 I've to send a mail from database to my mail-id with attachment. EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Adventure Works Administrator', @recipients = 'danw@Adventure-Works.com', @query = 'SELECT COUNT(*) FROM AdventureWorks2012.Production.WorkOrder WHERE DueDate > ''2004-04-30'' AND DATEDIFF(dd, ''2004-04-30'', DueDate) < 2' , @subject = 'Work Order Count', @attach_query_result_as_file = 1 ; from this code i'm getting result in txt file. but i want to get query result in pdf file or

Temporary tables using JDBC with null ResultSet

三世轮回 提交于 2020-01-01 10:48:07
问题 I am executing a stored procedure via standard JDBC Connection using MS SQL Driver version 3.0 . I have found that when I create and insert data into a temporary table the stored procedure doesn't execute properly. The Java code won't throw a exception, but the javax.sql.ResultSet will be null . The point of failure in the stored procedure is when I un-comment the INSERT INTO #TBL CLM_NAME VALUES('VAL') When I execute the statement using SQL Studio Manager it executes without hassle and the

How can I script an MS SQL Server database with proper object ordering?

别来无恙 提交于 2020-01-01 10:16:14
问题 I'm trying to script an MS SQL Server 2005 database to a single file. So far I've tried using SQL Management Studio and the MS Database Publishing Wizard. Both tools will script the database objects without a problem although neither tool is scripting objects in the right order of creation. For instance the script might script a view which requires a table that's not going to be created until later down the line. Do you know how to script the database schema with the proper order of object

Take the time from the datetime and convert it into seconds?

耗尽温柔 提交于 2020-01-01 08:51:48
问题 I am running SQL Server 2005. Technically I know how to take the time from a tsql datetime. CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond The problem is that I have a datetime field and I need to essentially grab the time portion convert that to an integer specifically seconds. Then I need to do a bunch of arithmetic on this integer that I won't discuss here. I have searched on stackoverflow and haven't found a question that is specific to this question. Any ideas? I am really looking

Take the time from the datetime and convert it into seconds?

喜欢而已 提交于 2020-01-01 08:50:06
问题 I am running SQL Server 2005. Technically I know how to take the time from a tsql datetime. CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond The problem is that I have a datetime field and I need to essentially grab the time portion convert that to an integer specifically seconds. Then I need to do a bunch of arithmetic on this integer that I won't discuss here. I have searched on stackoverflow and haven't found a question that is specific to this question. Any ideas? I am really looking

SQL Server 2005 deadlock with nonclustered index

孤街醉人 提交于 2020-01-01 08:40:13
问题 Can anybody help me for a deadlock in SQL Server 2005? For a simple test, I have a table "Book" which has a primary key (id), and a column name. The default index of this primary key is nonclustered . The deadlock happens when two sessions run at a same time. Activity monitor shows the first session "//step 1" locks the row(rid lock) with X lock. The second session keeps row U lock and key U lock. The deadlock picture shows "//step2" of first session requires key U lock. If the index is

Cannot resolve collation conflict in Union select

限于喜欢 提交于 2020-01-01 08:36:08
问题 I've got two queries: First doesn't work: select hotels.TargetCode as TargetCode from hotels union all select DuplicatedObjects.duplicatetargetCode as TargetCode from DuplicatedObjects where DuplicatedObjects.objectType=4 because I get error: Cannot resolve collation conflict for column 1 in SELECT statement. Second works: select hotels.Code from hotels where hotels.targetcode is not null union all select DuplicatedObjects.duplicatetargetCode as Code from DuplicatedObjects where