RAISERROR QUERY
IF EXISTS (select GETDATE() 'Today Date',date_value 'expiry date', abs(DATEDIFF(dd,date_value,getdate()))'No of days before expiry' from dbo.Test_X where Application_Name='xyz'AND...
View Articleimpact of assigning dbowner privelege to a user/login
Hello,If I assign dbowner privelege to a login/user would that user be able to access all the objects in that specific database or the objects owned by the user only.Best regards,Vishal
View ArticleRrecursive foreign keys
I need hlep for one query.I have on DB where we have 350+ tables. I just want to get the list of tables which have recursive foregin keys.Like Table A Link to Table B and Table B Link to Table A.Thanks
View ArticleGet distinct records if more than one select column
Hi,I have a table . ParentId refid TaskNo [TaskOwner] [UpdatedBy] Remarks Description 100 NULL 100 user2 user2 hi hi 100 100 100.1 user1 user1 this this 100 100.2 100.2.1 user2 user1 is is 101 NULL...
View ArticleNeed a PIVOT-like solution
I have a stored procedure based on a primary table that has multiple rows for different dates within a year. I want the result set to display all dates as separate columns. Normally there are no more...
View Articlelinked server issue on sql 2000 sp4
i am getting below error while running a select statement with linked server to oracle provider with oledb.Server: Msg 7399, Level 16, State 1, Line 1 OLE DB provider 'OraOLEDB.Oracle' reported an...
View ArticleWhere, Group By, Having, Order --- Usage sequence?
HiCan anyone tell me the sequence in which below clauses can be placed:Where, Group By, Having, Order byMoreover can we use Having after where and before Group By? Thanks!! http://gurunguns.wordpress.com
View ArticleOne Clustered Index
Why only one clustered Index in SQL Server? Can you please explain in more detail?
View ArticleCan Windows Task Scheduler call a SProc?
I am using SQL Server Express, which does not come with SQL Agent, so I can't schedule tasks with that. However, I can easily use the Windows Task Scheduler to run a batch file, and with that I can...
View Article[SQL 2012] split string with forbidden characters
Hi all, I have an issue with a queryI would like to find an equivalent of pivot function, but with a column that contains forbidden characters (like []&) and using delimiter (,), and when number of...
View ArticleHow to Identify All Records = xxxxxx:
Hi I have a list of identifiers in my database which look like this: 1234234234:2Some of the identifiers have a missing digit after the colon, and I am wondering how I can identify them from the rest...
View ArticleList of Values to Stored Procedure.
Hi,I wrote a SP to pass a value to SP. It works wellALTER PROC [dbo].[getCompleteItems] (@p_ItemID varchar(32)) AS DECLARE @IntVariable char(32); DECLARE @SQLString NVARCHAR(500); DECLARE...
View ArticleSp to call another SP if all the latest packages ran successfully
Hi-I have 3 ssis packages, If in the recent execution all the packages ran successfully then another SP has to run. I have created a audit table which keeps the package info. Below is the audit...
View ArticleNeed to include duplicate records in sub query
Hi All, I am using the following query and i am getting error message that your sub query return dupliate records and throwing error. Actually i need these duplicate records for my report. I...
View ArticleConvert multiple rows in a table into one row based on the primary key
I have 2 tablesCREATE TABLE Files (FileID int, fileName varchar(20)) insert into Files values (1,'F1') insert into Files values (2,'F2') insert into Files values (3,'F3') CREATE TABLE Versions (FileID...
View ArticleTruncate table lock issue
Hi, In my SQL2000 stored procedure, there are 9 truncate table commands. But the the stored procedure is take above 15 minutes to execute. In this stored procedure, truncate table command...
View Articlecase statement to replace union all
Need advice on case statement to replace union allWant to implement case and remove union allSELECT ,[MONTH] ,[YEAR] ,[A] ,[B] ,[C] ,[D] ,[E] ,'HELLO' as STRING1 ,'HI' AS STRING2 ,SUM(E) as metric1...
View Articlewhen i run this i get the error -Arithmetic overflow error converting...
create table [New1] ([Posting Date] date references [sample].[dbo].[Posting Date_PRL]([Posting Date]), [Order No] nvarchar(20) collate Latin1_General_100_CS_AS references [sample].[dbo].[Order...
View ArticleProblem with a Sub-SELECT statement. Need Help...
Hi there everybody. First of all, the following DB schema is not mine and I have to work with it, and I'm not allowed to modify it.Let's say I've got 3 tables :- A list of Persons. - A list of...
View Article