RcBuilder@walla.com
call centre: 054-5614020

Entity Framework Data Annotations

Posted by: RcBuilder  /   Category: ADO.NET / Entity Framework / SQL / SQL Data Types   /   No Comments
30
Oct
2014

Entity Framework Data Annotations * Data Annotations are attributes that specify the following: 1. a validation rules 2. how the data is presented 3. how the data will be mapped to the database * add the following namespaces: - using System.ComponentModel.DataAnnotations; - using System.ComponentModel.DataAnnotations.Schema; * we can combine multi annotations within the same brackets e.g: * - schema attribute - set the property as PK.

Read more

SQL COLLAPSE example

Posted by: RcBuilder  /   Category: SQL / SQL Data Types / SQL Function / Stored Procedure / System Function   /   No Comments
20
Oct
2014

SQL COLLAPSE - multiple rows to single value we can use the COLLAPSE sql function to concatenation values into a single string data declare @tbl2 table(Name nvarchar(10), Quantity int, CreatedDate smalldatetime) insert into @tbl2 SELECT 'Roby', 100, '2009-12-05' UNION ALL SELECT 'Avi', 40, '2011-11-05' UNION ALL SELECT 'Avi', 60, '2010-05-03' UNION ALL SELECT 'Avi', 15, '2009-06-11' UNION ALL SELECT 'Ron', 50, '2010-04-11' UNION ALL SELECT 'Roby', 77,.

Read more

SQL PIVOT

Posted by: RcBuilder  /   Category: DATES / DBA / SQL / SQL Data Types / SQL Function / Stored Procedure   /   No Comments
07
Oct
2014

SQL PIVOT creates an horizontal group by. MUST define the groups names. structure pivot(<aggregation function> FOR <group by column> IN (<group by column values>)) USING example 1: declare @tbl1 table(Name nvarchar(10), Quantity int) insert into @tbl1 SELECT 'Roby', 100 UNION ALL SELECT 'Avi', 40 UNION ALL SELECT 'Avi', 60 UNION ALL SELECT 'Avi', 15 UNION ALL SELECT 'Ron', 50 UNION ALL SELECT 'Roby', 77 UNION ALL SELECT 'Roby', 12 UNION.

Read more

Split SQL FUNCTION

Posted by: RcBuilder  /   Category: SQL / SQL Data Types / SQL Function / Stored Procedure / System Function   /   No Comments
23
Sep
2014

Split SQL FUNCTION  create FUNCTION Split ( @String nvarchar (MAX), @Delimiter nvarchar (5) = ',' -- use the keyword 'DEFAULT' in order to use the default parameter ) RETURNS @ValueTable table ( nvarchar(50)) AS BEGIN if(RTRIM(LTRIM(@String)) = '') return declare @NextString nvarchar(50) declare @Pos int declare @NextPos int declare @CommaCheck nvarchar(1) --Initialize set @NextString = '' set @CommaCheck = right(@String,1) --Check for trailing Comma, if not exists, INSERT --if (@CommaCheck <> @Delimiter ) set @String =.

Read more

make database tables copy using fetch next

Posted by: RcBuilder  /   Category: FETCH NEXT / Master / Replication / SQL / SQL Data Types / SQL Function / Stored Procedure   /   1 Comment
01
Jul
2014

make database tables copy using fetch next declare _cursor CURSOR FOR SELECT TABLE_NAME, TABLE_SCHEMA FROM information_schema.tables OPEN _cursor declare @currTABLE nvarchar(50), @currSCHEMA nvarchar(50) FETCH NEXT FROM _cursor INTO @currTABLE, @currSCHEMA -- first row -- WHILE @@FETCH_STATUS = 0 BEGIN BEGIN TRY exec('select * into copyDB.' + @currSCHEMA + '.' + @currTABLE + ' from '+ @currTABLE) --select @currSCHEMA + '.' + @currTABLE END TRY BEGIN CATCH PRINT('ERROR :.

Read more

SQL recursive using CTE

Posted by: RcBuilder  /   Category: DBA / SQL / SQL Data Types / SQL Function / Stored Procedure   /   1 Comment
08
May
2014

SQL recursive using CTE Data source Id Name Parent 1 'ROOT ITEM NULL 2 'PARENT 1' '1' 3 'PARENT 2' '1' 4 'PARENT 3' '1' 5 'PARENT 1' 'SON 1 2' 6 'PARENT 1' 'SON 2 2' 7 'PARENT 1' 'SON 3 2' 8 'PARENT 2' 'SON 1 3' 9 'PARENT 2' 'SON 2 3' 10 'PARENT 2' 'SON 3 3' 11 'PARENT 2' 'SON 4 3' 12 'PARENT.

Read more

SQL datetime – seconds rounded automatically

Posted by: RcBuilder  /   Category: BUGS / SQL / SQL Data Types   /   No Comments
04
May
2014

Bug: the seconds node of the date time object have been rounded Problem: the data type 'smalldatetime' round the seconds of the date automatically fix: replace to 'datetime' data type example: declare @dt datetime set @dt = GETDATE() select @dt // 2014-03-05 15:45:35.533 declare @dt smalldatetime set @dt = GETDATE() select @dt // 2014-03-05.

Read more
12
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים