منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
ارجو تحويل الكود الى sql - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم قواعد البيانات (http://vb4arb.com/vb/forumdisplay.php?fid=40)
+--- قسم : قسم مقالات SQL SERVER (http://vb4arb.com/vb/forumdisplay.php?fid=84)
+--- الموضوع : ارجو تحويل الكود الى sql (/showthread.php?tid=32234)



ارجو تحويل الكود الى sql - safnnn - 24-11-19

select tabel1.name1,tabel1.txt, tabel1.id, sum(iif (test1.teep=1,test1.mony, 0)) as ouut, sum(iif (test1.teep=0,test1.mony, 0))as book,iif(book-ouut>0,book-ouut,(book-ouut)*-1) as good,iif(book-ouut>0,'no','yas') as video from tabel1 inner join test1 on tabel1.id = test1.id where 1=1 group by tabel1.name1,tabel1.txt, tabel1.id


RE: ارجو تحويل الكود الى sql - natelik - 19-03-20

"The sample tables used in this Product Brief can be created with the data provider, as shown in the following code example:\r\n\r\nSQLServerConnection Conn;\r\nConn = new SQLServerConnection(\"host=nc-star;port=1433;\r\nUser ID=test01;Password=test01; Database Name=Test\");\r\ntry\r\n{\r\nConn.Open();\r\n}\r\ncatch (SQLServerException ex)\r\n{\r\n\/\/ Connection failed\r\nConsole.WriteLine(ex.Message);\r\nreturn;\r\n}\r\nstring[] DropTableSQL = {\"drop table emp\", \"drop table dept\"};\r\nfor (int x=0; x<=1; x++)\r\n{\r\ntry\r\n{\r\n\/\/ Drop the tables, don't care if they don't exist\r\nSQLServerCommand DBCmd = new SQLServerCommand(DropTableSQL[x], Conn);\r\nDBCmd.ExecuteNonQuery();\r\n}\r\ncatch (SQLServerException ex)\r\n{\r\n}\r\n\/\/ Create the tables\r\nstring CreateEmpTableSQL = \"CREATE TABLE emp\r\n(empno INT PRIMARY KEY NOT NULL,\"\r\n+\"ename VARCHAR(10) NOT NULL,\"\r\n+\"job VARCHAR(9) NOT NULL,\"\r\n+\"mgr INT,\"\r\n+\"hiredate DATETIME NOT NULL,\"\r\n+\"sal NUMERIC(7,2) NOT NULL,\"\r\n+\"comm NUMERIC(7,2),\"\r\n+\"dept INT NOT NULL)\";\r\nstring CreateDeptTableSQL = \"CREATE TABLE dept (\"\r\n+\"deptno INT NOT NULL,\"\r\n+\"dname VARCHAR(14),\"\r\n+\"loc VARCHAR(13))\";\r\ntry\r\n{\r\nSQLServerCommand DBCmd = new SQLServerCommand(CreateEmpTableSQL, Conn);\r\nDBCmd.ExecuteNonQuery();\r\nDBCmd.CommandText = CreateDeptTableSQL;\r\nDBCmd.ExecuteNonQuery();\r\n}\r\ncatch (Exception ex)\r\n{\r\n\/\/Create tables failed\r\nConsole.WriteLine (ex.Message);\r\nreturn;\r\n}\r\n\/\/ Now insert the records\r\nstring[] InsertEmpRecordsSQL = {\r\n \"insert into emp values\r\n (1,'JOHNSON','ADMIN',6,'12-17-1990',18000,NULL,4)\",\r\n \"insert into emp values\r\n (2,'HARDING','MANAGER',9,'02-02-1998',52000,300,3)\",\r\n \"insert into emp values\r\n (3,'TAFT','SALES I',2,'01-02-1996',25000,500,3)\",\r\n \"insert into emp values\r\n (4,'HOOVER','SALES I',2,'04-02-1990',27000,NULL,3)\",\r\n \"insert into emp values\r\n (5,'LINCOLN','TECH',6,'06-23-1994',22500,1400,4)\",\r\n \"insert into emp values\r\n (6,'GARFIELD','MANAGER',9,'05-01-1993',54000,NULL,4)\",\r\n \"insert into emp values\r\n (7,'POLK','TECH',6,'09-22-1997',25000,NULL,4)\",\r\n \"insert into emp values\r\n (8,'GRANT','ENGINEER',10,'03-30-1997',32000,NULL,2)\",\r\n \"insert into emp values\r\n (9,'JACKSON','CEO',NULL,'01-01-1990',75000,NULL,4)\",\r\n\"insert into emp values\r\n (10,'FILLMORE','MANAGER',9,'08-09-1994',56000, NULL,2)\",\r\n \"insert into emp values\r\n (11,'ADAMS','ENGINEER',10,'03-15-1996',34000, NULL,2)\",\r\n \"insert into emp values\r\n (12,'WASHINGTON','ADMIN',6,'04-16-1998',18000,NULL,4)\",\r\n \"insert into emp values\r\n (13,'MONROE','ENGINEER',10,'12-03-2000',30000,NULL,2)\",\r\n \"insert into emp values\r\n (14,'ROOSEVELT','CPA',9,'10-12-1995',35000,NULL,1)\"};\r\nstring[] InsertDeptRecordsSQL = {\r\n \"insert into dept values (1,'ACCOUNTING','ST LOUIS')\",\r\n \"insert into dept values (2,'RESEARCH','NEW YORK')\",\r\n \"insert into dept values (3,'SALES','ATLANTA')\",\r\n \"insert into dept values (4, 'OPERATIONS','SEATTLE')\"};\r\n\/\/ Insert dept table records first\r\nfor (int x = 0; x<InsertDeptRecordsSQL.Length; x++)\r\n{\r\ntry\r\n{\r\nSQLServerCommand DBCmd =\r\n new SQLServerCommand(InsertDeptRecordsSQL[x], Conn);\r\nDBCmd.ExecuteNonQuery();\r\n}\r\ncatch (Exception ex)\r\n{\r\nConsole.WriteLine (ex.Message);\r\nreturn;\r\n}\r\n}\r\n\/\/ Now the emp table records\r\nfor (int x = 0; x<InsertEmpRecordsSQL.Length; x++)\r\n{\r\ntry\r\n{\r\nSQLServerCommand DBCmd =\r\n new SQLServerCommand(InsertEmpRecordsSQL[x], Conn);\r\nDBCmd.ExecuteNonQuery();\r\n}\r\ncatch (Exception ex)\r\n{\r\nConsole.WriteLine (ex.Message);\r\nreturn;\r\n}\r\n}\r\nConsole.WriteLine (\"Tables created Successfully!\");\r\n\/\/ Close the connection\r\nConn.Close();"
Speed Test Scrabble Word Finder Solitaire