sql-server

Changes to a Query Based on Year

select datepart(month,s1.Timeperiod) as monthofaum, datepart(YEAR,s1.Timeperiod) as Yearofaum, ISNULL(s2.endingAum,0) as Starting_Aum, s1.endingAum as Ending_Aum from #temp_1 s1 left outer join (select * from #temp_1)s2 on month(s1.Timeperiod) = dateadd(D,1,month(s2.Timeperiod)) This w...

Use SQL instead of Delete and End from keyboard

Hi, I am running a simple statment below which gives the output as follow: select '''' + name + '''' + ',' as Emp_Names from dbo.employee Emp_Names 'Jason', 'Robert', 'Celia', 'Linda', 'David', 'James', 'Alison', 'Chris', 'Mary', Is there a way in SQL that can show my desired output as: Emp_Names 'Jason', 'Robert','Celia'...

Is it okay to use table look up functionalities in scalar function?

In our case we have some business logic that looks into several tables in a certain order, so that the first non null value from one table is used. While the look up is not hard, but it does take several lines of SQL code to accomplish. I have read about scalar valued functions in SQL Server, but don't know if the re-compliation issue af...

SQL Server 2005 - SSIS validation error server-side only

Hi, I am deploying some integration services into a SQL Server 2005. On my computer, I don't have any validation error but I do on the server. It comes from an OLE DB connection manager: "Login failed for user 'rw_user'". Whereas I can fully run it on a client, the connection works perfectly. This is a connection to the server itself....

Noddy question on Relationship sql server between 2 tables.Can you clarify?

Hi, apologise for silly question but there you go. Sql server 2 tables Customer and Order A customer can only have one order. When using the Sql server diagram and you want to create a relationship between the customer.CustomerId and order.CustomerID ,which way do you drag the arrow? From the customer to the order or from the order to ...

SQL Server 2000 database query

I have three tables: question (qId,qTitle) student (studentId,studentName) marks (studentId,qTitle,qMark) I want to do is: when a teacher is logged in then he is able to see all the record combining above three tables. If student do any question then its entry store in marks table. I want to join all three tables so that all qTit...

Is there a free GUI tool for data sync between DB in which it is possible to script rules?

What I need to do is some data between 2 databases. The source can be anything (comma separated file, xls file, any database, ...), the destination is MS SQL Server. I do not need to sync all data, I just need to sync particular tables. Example: I need to sync accounting Software (runs on PostgreSQL) CUSTOMERS table with CRM (runs on ...

Indexing in SQL Server

Could somebody please explain how indexing works in SQL Server and what is a clustered and non clustered index? When we create an index on some column how does it increase the performance and how are the values of column stored to increase the performance? ...

SQL Server SSIS Warning :0x80000036

I have updated my SQL Server 2008 R2 Evaluation Edition to Enterprise Edition a couple of weeks ago. Service Pack 1 is also installed. Things were going good for a while . But when I run an SSIS package now, I get a Warning: 0x80000036: only 9 days left for evaluation. can anyone help me out in resolving this issue? ...

Which db is more scalable mnesia or external db like SQL Server for RabbitMQ

If I want to use multiple rabbitmq with their own database mnesia. Is mnesia good or any external database like SQL Server for holding bulk of data. ...

How do you find a missing number in a table field starting from a parameter and incrementing sequentially?

Let's say I have an sql server table: NumberTaken CompanyName 2                      Fred 3                      Fred 4                      Fred 6                      Fred 7                      Fred 8                      Fred 11                    Fred I need an efficient way to pass in a parameter [StartingNumber] an...

Using SQL Server spatial types in SSIS data load

Hi there, I am trying to load a file using the SQL Server Import Data function - appending rows to an existing table. my existing table is created like this: CREATE TABLE [dbo].[load]( [Long] [varchar](50) NULL, [Lat] [varchar](50) NULL, [Geog] AS ([geography]::STGeomFromText(((('POINT('+[Long])+' ')+[Lat])+')',(4326))) )...

Assign user permission in SQL Server database

Hi, Is there anyway using query that I can assign permissions to user in a SQL Server database? Thanks ...

How is Kana sensitivy applied to non-Japanese letters?

Why is Kana Sensitivity applied to Latin and Cyrillic collations? i.e. "_KS" in, for ex., Latin1_General_100_CS_AI_KS I tried to search for Kana and get exactly what I expected: When Japanese kana characters Hiragana and Katakana are treated differently, it is called Kana sensitive. How is it applied to Latin letters? What am I l...

Printing tree with SQL CTE

Hi The schema is as follows: CREATE TABLE [Structure]( [StructureId] [uniqueidentifier] NOT NULL, [SequenceNumber] [int] NOT NULL, -- order for siblings, unique per parent [ParentStructureId] [uniqueidentifier] NULL, CONSTRAINT [Structure_PK] PRIMARY KEY CLUSTERED ( [StructureId] ASC ) ) ON [PRIMARY] ALTER TABLE [Str...

Select All Right Hand Rows for Each Left Hand Row SQL.. HELP!

Hello, I am currently looking for a Select statement which will do this.. |------Apples------| |--id--| - 1 - 16 - 23 - 42 |------Oranges------| |--id--| - a - b - c *SELECT STATEMENT* |------Fruit Cocktail------| |--AppleID--|--OrangeID--| 1 a 1 b 1 c 16 ...

How to rollback if any update is not success?

I have written a transaction like: BEGIN TRAN UPDATE [Table1] SET [Name] = 'abcd' WHERE [ID] = 1 UPDATE [Table2] SET [Product] = 'efgh' WHERE [ID] = 10 UPDATE [Table3] SET [Customar] = 'ijkl' WHERE [ID] = 11 Now I want to rollback if any UPDATE is not success. For example in Table2 i...

Like query on Date Time

Hi friends,is this possible to fire like query on DateTime in SQL Server 2005. select cur.EvrIdent, cur.VrdTarih, cur.VrdModTim, cur.VrdNo, (select PmpKod from Bnz_Pompalar where PmpIdent=(select GunPmpId from Bnz_Tabancalar where GunIdent=TbdGunId)) as [Pump No], (select GunKod from Bnz_Tabancalar where GunIdent=TbdGunId) as [Nozzle No...

Delphi XE Unicode dealing with nchar(1) fields

Hello I'm using a dbGo TADODataset in Delphi XE to read data from a SQL Server 2008 table. All the string fields are nvarchar or nchar. The nvarchar fields map to TWideStringField with no problems. The problem is with an nchar(1) field, this maps to a TStringField fine but not to a TWideStringField - when I configure the field to be T...

How can I pass a list of object in a SQL Procedure with SQL Server 2008 ?

How can I pass a list of object in a SQL Procedure with SQL Server 2008 ? I want to avoid this : foreach (var item in itemList) { myContext.ExecuteStoreCommand("EXEC MyAtomicProc ... item ...); } I want to do the foreach in a store procedure. How can I pass a c# list of object and execute this procedure in EF : myContext.Execut...