• Breaking News

    Sunday, November 26, 2017

    Self-taught programmers, how long did it take you to get your first job? learn programming

    Self-taught programmers, how long did it take you to get your first job? learn programming


    Self-taught programmers, how long did it take you to get your first job?

    Posted: 26 Nov 2017 01:29 PM PST

    For people who are completely self-taught and do not have any degree related to computer science:

    • How long did you study for? And for how many hours per week?

    • Without a CS degree, did you have trouble getting companies to call you for an interview? How long did your job search go for?

    • What was your first job?

    • Relative to market rate, were you severely underpaid at your first job? And if you're no longer at your first job, are you underpaid now?

    submitted by /u/LaDolphin
    [link] [comments]

    First Ever Video - Github Basics for the Unacquainted

    Posted: 26 Nov 2017 10:15 AM PST

    I just made my first video for GitHub. Check it out! Any feedback is appreciated.

    https://youtu.be/Qa-MLHDCSLo

    submitted by /u/netwhoo
    [link] [comments]

    [C++] why does getline sometimes gets skipped?

    Posted: 26 Nov 2017 10:57 PM PST

    I started my code with getline but later on, after using cin multiple times, getline gets skipped when I run my code. What causes this?

    submitted by /u/AR96
    [link] [comments]

    [php/html forms] Having trouble with the isset() funciton, returning true even when nothing filled out in textbox. Am I doing something wrong? How can I get it so that the text is only printed when I've hit submit AND there's text in the textbox?

    Posted: 26 Nov 2017 09:26 PM PST

    Here's my code:

    echo <<<_TITLE <html> <head><title>This is just a test</title></head> <body> _TITLE; if (isset($_POST["submit"],$_POST["text"])){ echo 'submit and text were both set!'; } echo <<<_BODY <form method="post" action="main.php"> <input type="text" width="32" name="text"> <input type="submit" value="submit" name="submit"> </form> </body> </html> _BODY; ?> 

    Basically, when I hit submit, "submit and text were both set!" still prints EVEN WHEN I've not put any text in the text box. Therefore, somehow isset($_POST['text']) is returning true somehow but I would think this is only the case when there is actually text in the textbox. Otherwise, what is the point? When is it ever false. Am I doing something wrong?

    Also, I just now noticed that the text is also printed when I put my cursor in the textbox, type no text, and hit enter. I would imagine that it should only pass when there's text AND I click submit. I really don't understand :(

    submitted by /u/puremath369
    [link] [comments]

    Leet Code Help - Faulty "Wrong Answers"

    Posted: 26 Nov 2017 10:30 PM PST

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.

    Test case = "MMDCCXVIII" Output = 2716 Expected = 2718 

    In Visual Studio my output is 2718 making my program run fine, but I'm confused as to what the issue is in Leetcode.

    A minimal, easily runnable, and well formatted program that illustrates your problem

    What would "minimal" be in my example code? I'm not sure where I went wrong so I'm gonna display it all. If there's a way to condense my code I would love the feedback to improve as a programmer and also with reddit's formatting.

    Code: class Solution { public: //function that determines the value of a Roman numeral character int getRomanCharValue(char letter) { switch (letter) { case 'I': return 1; case 'V': return 5; case 'X': return 10; case 'L': return 50; case 'C': return 100; case 'D': return 500; case 'M': return 1000; default : return 0; } } // Determines the length of a string int strLen(string word) { int strLen = 0; while (word[strLen] != NULL) { word[strLen]; strLen++; } return strLen; // Returns the size of a string } // Returns the value of a roman numeral string into an integer value int romanToInt(string s) { if (s == "MLXXIV") return 1074; // Variable Declarations char *input; // Dynamic array that will hold the input "s". int inputLength = 0; // Determines size of input from length of "s" int *romanValues; // Dynamic array for placing converted roman numeral values into int add = 0; // Returns the final value of the Roman numeral inputLength = strLen(s); input = new char[inputLength]; romanValues = new int[inputLength]; // Places each letter of input "s" into input[] at index i // Replaces the roman numerals with integers for (int i = 0; i < inputLength; i++) { input[i] = s[i]; romanValues[i] = getRomanCharValue(input[i]); } //Adds up the roman numerals for (int i = 0; i < inputLength; i++) { if (romanValues[i] >= romanValues[i+1] && romanValues[i+1] != NULL) { add = add + romanValues[i]; // Adds the value of romanValues[i] into "add". } else if (romanValues[i] < romanValues[i+1] && romanValues[i+1] != NULL) // Takes into account 4's and 9's in Roman Numeral { add = add - (romanValues[i]); // Subtracts the value if when compared was lower than the next number } if (romanValues[i+1] == NULL) // The last letter will not be compared and just be added. { add = add + romanValues[i]; } } return add; // Returns the value of the input } 

    };

    submitted by /u/DjSwaggySwag_
    [link] [comments]

    10 Week "Python Projects" class [Santa Clara] Nov28-Feb13

    Posted: 26 Nov 2017 10:19 PM PST

    Dear Neighbors,

    For Software-Techies, I invite you to my Project Based Python Programming class:

    https://register.asapconnected.com/CourseDetail.aspx?CourseId=136006&ext=1

    It meets on Tues night 7pm to 10pm.

    The location is Santa Clara Adult Education Campus.

    Address: 1840 Benton St. Room F4

    The class has 10 meetings: Tues Nov 28 through Feb 13.

    Cost: $329 [ covers class and significant e-mail support ]

    Class pace is FAST and topic list is VAST; you will get your money's worth.

    If you fall behind, dont worry; I will answer help-requests during the session and after Feb 13.

    Also the class offers an online forum to help you connect with the instructor and other students.

    Format:

    • Lectures cover Python syntax and techniques
    • Homework is: Build Projects with Python

    Lecture Topics:

    • Python 3.x
    • Anaconda Python
    • Jupyter
    • Pycharm
    • Spyder
    • Simple Linux
    • Python-Linux Development Environments
    • Python-Linux Production Environments
    • Common type conversions
    • Pandas
    • datetime
    • strftime(),strptime()
    • pdb
    • matplotlib
    • Lists, Loops, Comprehensions, range()
    • Strings, "Python Dunders"
    • CSV files
    • Python Class Inheritance
    • Functions vs Methods
    • Flask web-apps
    • Simple HTML, CSS, JavaScript
    • Jinja2 template engine for Python
    • Web scraping with Requests and BeautifulSoup
    • Deploy Python-app to Heroku for $0
    • The "os" package
    • Team collaboration with github.com
    • Flask-RESTul web-apps
    • Intro JSON
    • Intro Machine Learning: Scikit-Learn
    • NumPy + Pandas + Machine Learning
    • Keras Machine Learning
    • SQLAlchemy + Postgres
    • Selenium
    • Data Visualization: Bokeh
    • Data Visualization: Seaborn
    • Natural Language Processing (NLP): Word2vec
    • TensorFlow Python API + Machine Learning
    • Python Collections Package
    • Django web-apps
    • Python + Regular Expressions

    If you have questions, e-me: bikle101 at gmail

    submitted by /u/mooctutor
    [link] [comments]

    Can somebody ELI5 function pointers and why somebody would use them?

    Posted: 26 Nov 2017 09:02 PM PST

    I'm currently reading about function pointers in a CS textbook and I'm a bit confused by them. How and why would you use a function pointer?

    submitted by /u/aPokemon
    [link] [comments]

    becoming an android developer?

    Posted: 26 Nov 2017 09:02 PM PST

    Hello developers, I'm a 26 year old man graduated last year with degree in engineering but have no coding experience and have recently wanted to become a android developer.

    1. So Java is used mainly for the development and Kotlin which was introduced recently I believe. Is it uncommon to self teach android developing and land an entry level position?

    2. Would Java be a little too overwhelming for someone with no coding experience?

    3. Any additional advice would be great.

    thank you

    submitted by /u/jifewgef
    [link] [comments]

    How to implement an IP check for a voting application

    Posted: 26 Nov 2017 10:03 PM PST

    So voting sites such as www.strawpoll.me implement a system that checks for duplicate IP addresses so that users can't vote more than once by simply logging into a different browser or clearing their cookies if there is a cookie checking block. I need to know how this is accomplished so that I can implement it into my own project.

    submitted by /u/nodnarbiter
    [link] [comments]

    [Java] Read a byte array off incoming stream

    Posted: 26 Nov 2017 09:48 PM PST

    I'm looking for a way to wait until bytes are available in the stream and then read an entire byte array of x bytes, (pushed onto the stream as a byte array on the sender's end)?

    I envision a while loop waiting for bytes to be available on the input stream, read the bytes into a byte array when bytes become available and then goes back to waiting for more bytes.

    Thanks.

    submitted by /u/krisdi
    [link] [comments]

    Free code camp vs The Odin project

    Posted: 26 Nov 2017 02:15 PM PST

    I feel very stuck between the two. While I think I'd rather learn javascript and the MEAN stack over Ruby and RoR (which i am also interested in) I much prefer the odin projects way of doing things. Everything on FCC seems to be in browser and you don't get a feel for a real development environment. TOP on the other hand dive straight into setting up your own environment and teaching you git , github and heroku. I feel like I'll learn exactly what i want with FCC but have no experience with a real development environment while with TOP I'll learn something similar but get lots of practice in other important areas. Any suggestions on which to go with based on that? Is there any other free course that I've missed that covers FCC content but in your own dev environment?

    submitted by /u/FullyStacked92
    [link] [comments]

    Certification courses for CS freshman for Internships

    Posted: 26 Nov 2017 09:27 PM PST

    My younger brother recently started his Undergrad in Computer science. This coming winter break I want him to self study and gain some certification(s) to help him land an internship this coming summer. Can you please recommend some beginner level IT or Programming courses with certifications (preferably cheap) that I can recommend to him.

    He is studying in an US institution as an international student. He is currently taking two intro level Computer science courses which uses Python.

    submitted by /u/bkhan19
    [link] [comments]

    If am getting into learning, what is the best method? Should I take CS50 or read a book like Automate the Boring Stuff with Python?

    Posted: 26 Nov 2017 08:49 PM PST

    Doesn't matter what language I start with.

    submitted by /u/twistnr
    [link] [comments]

    Is the main function of git branches for version control?

    Posted: 26 Nov 2017 10:18 PM PST

    So my list of branches initially look like this:

    master

    After I make changes I'll create a new branch called version 1.1

    So eventually a while later my git branches would look like this:

    master

    version 1.1

    version 1.2

    version 1.3

    etc

    Am I on the right track?

    submitted by /u/GerrardSlippedHahaha
    [link] [comments]

    Dev C++ Alternative to Linux?

    Posted: 26 Nov 2017 11:01 PM PST

    Hi!

    I managed to install DevC++ on my machine but i can't use it.Can someone suggest me another alternative ?

    I have tried Geany, but i don't seem to have a nice time with it.

    submitted by /u/RyderNigger
    [link] [comments]

    Dumb question about why to use scripting languages.

    Posted: 26 Nov 2017 08:33 PM PST

    So I still don't really understand the point of scripting languages and I'm embarrassed. I'm a programmer professionally for a few years now and I don't really understand what the point of ruby, python, and Javascript is. I get that the languages themselves have things that are useful like some features of ruby. I've been working in c languages mostly and c# professionally.

    I had a project that my girlfriend gave me an idea for. A program to make some aspects of her job easier. I thought this would be a good time to learn a good scripting language since I was told they'd be good to have under my belt.

    I looked into ruby or python and... I didn't see a reason to use them. It's for a windows computer, I wanted a gui and if I pick a compiled language I can package the program up for her to install and use. I even use Javascript at work but I tend to stick mostly to doing things in c#. So, why would I use ruby where I could use Java or c#? I would need an interpreter and it doesn't seem easier unless there's an aspect of ruby for example that I need.

    submitted by /u/thekidxp
    [link] [comments]

    [c++] I have to do this program where I find the total weight of 5 people using arrays. whats wrong with this?

    Posted: 26 Nov 2017 10:11 PM PST

    include <iostream>

    using namespace std;

    int main() {

    double total(double value[], int size);

    double avg(double value[],int size);

    const int size = 5;

    double weight[size];

    for (int a=0;size>a;a++)

    {

     cout << "Enter weight "<< a+1; cin>>weight[a]; cout<<":"; cout << endl; } cout << "You entered: "; for (int a=0;a<size;a++) cout<<weight[a]<<" "; cout<<endl; 

    double totalNew = total(weight,size);

    cout<<"Total weight: "<<totalNew<<endl;

    return 0;

    }

    submitted by /u/Im-A-W1zard
    [link] [comments]

    Learning C++ programming, but what about compiling?

    Posted: 26 Nov 2017 07:52 PM PST

    I've been programming in Python for a few years. I'm about to start working my way through Accelerated C++ by Koenig & Moo to get up to speed with C++. I realize Accelerated C++ doesn't cover C++11 and C++14, but the idea is for me to use a relatively short (but good) book like Accelerated C++ to get the basics of C++, and then I'll use another resource to pick up the latest features of C++11 and C++14. I have Stroustrup's Programming, Principles and Practice as a backup reference, along with C++ Primer by Lippman, Lajoie and Moo. My goal is to learn C++ as fast as possible with the goal of doing scientific computing (which I'm currently able to get away with doing in Python).

    Anyway, one thing I realized about most C++ tutorial books (including the above 3 books, which everyone says are amazing) is that none of them actually go into details about compiling C++ code. Compiling C++ code looks daunting to me -- there are a ridiculous number of flags for command line compiling, and then there's the whole rabbit hole of Makefiles.

    One resource that I found useful for learning a little bit about compiling is something like www.learncpp.com. I know that online tutorials such as that website are not recommended for actually learning C++ programming itself, but the ~1-2 intro lessons about compiling a Hello World program looks useful; see http://www.learncpp.com/cpp-tutorial/06-writing-your-first-program/. Also, for example, the Accelerated C++ book comes with C++ source code downloadable from their website, and that has a bunch of Makefiles in it (useful even though I plan to write out each example code snippet myself to learn better).

    My question: I use a macbook, and apparently I should be using clang to compile my C++ code. Is that right? What would happen if I compiled my code using CC, GCC, gcc, gcc++, or clang++? All of those commands work on my terminal.

    Thanks!

    submitted by /u/quantumofgalaxy
    [link] [comments]

    How to build a scanning web app?

    Posted: 26 Nov 2017 07:37 PM PST

    I'm thinking of making it like a web app, but I'm not sure how that would work. We can use templates.

    In this database, I would be able to add items (scan), the database can automatically update inventory based on incoming and outgoing transactions, the database will be accessible to other staff members with permission.

    I can create locations for items in the database. Other users with permission can select the items they want, schedule pickup time, and submit, the database will send a notification to me(backend).

    submitted by /u/JoeHobbit
    [link] [comments]

    code compiles and runs but the two arrays I'm trying to compare are not comparing correctly, when two inputs in the same spot of each array match, the code is not recognizing it. Any help greatly appreciated.

    Posted: 26 Nov 2017 07:27 PM PST

    /* * Author: Con * 11/27/17 * */ import java.util.Scanner; import java.util.Arrays; public class DriversLicenseExam { public static void main(String[] args) { String inputTestScores[] = new String[10]; for(int i = 0; i < inputTestScores.length; i++) { Scanner in = new Scanner(System.in); System.out.print("Enter answer student selected: " + (i + 1) + " : "); inputTestScores[i] = in.nextLine(); } String rightAnswers[] = new String[]{"b", "d", "a", "a", "c", "a", "b", "a", "c", "d"}; int correct = 0; for(int i=0; i<10; i++) { if (inputTestScores[i].equals(rightAnswers[i])) { System.out.println("correct"); correct++; } else { System.out.println("Not correct"); } } if(correct >= 6) { System.out.println("Congratulations you passed with a score of: " + correct); } else { System.out.println("You failed with a score of: " + correct); } 

    } }

    submitted by /u/Con_50
    [link] [comments]

    [JavaScript] JSON From API Can't be Read

    Posted: 26 Nov 2017 07:08 PM PST

    I'm making a GET request to an API that I've written and is running locally on a different URL and port. From the Network tab in the console I can see that I get the JSON that I expect, so i think my request is fine.

    In my code I've tried show the result with

    JSON.stringify(Promise.resolve(MyApiRequest())) 

    and

    JSON.stringify(MyApiRequest()) 

    but on both of these the site just displays {} and the console gives the error

    SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data 

    My GET request function is

    export const MyApiRequest = () => fetch('http://localhost:12345/stuff', {mode: 'no-cors', headers: {'Access-Control-Allow-Origin': '*'}}) .then(response => response.json()); 
    submitted by /u/zdbvfrdeyhtgf
    [link] [comments]

    [SQL] A Big List of SQL Server Queries and commands

    Posted: 26 Nov 2017 02:35 AM PST

    Link to Gist

    Reddit has messed up the formatting, you can visit the above gist to see them in proper format.

    To create a Table ```

    CREATE TABLE TheNameOfYourTable ( ID INT NOT NULL IDENTITY(1,1), DateAdded DATETIME DEFAULT(getdate()) NOT NULL, Description VARCHAR(100) NULL, IsGood BIT DEFAULT(0) NOT NULL, TotalPrice MONEY NOT NULL, CategoryID int NOT NULL REFERENCES Categories(ID), PRIMARY KEY (ID) ); 

    ```

    To create a copy of table( doesnt create constraints like primary key, not null , indexes ect) SELECT * INTO NewTable FROM OldTable Eg. SELECT * INTO clos_ext_bkup FROM clos_ext;

    To create a copy of table with its data (create and insert) ``` SELECT expressions INTO new_table FROM tables [WHERE conditions]; SELECT employee_id AS contact_id, last_name, first_name INTO contacts FROM employees WHERE

    employee_id < 1000; ```

    The format of new_table is determined by evaluating the expressions in the select list. The columns in new_table are created in the order specified by the select list. Each column in new_table has the same name, data type, nullability, and value as the corresponding expression in the select list.

    Inserting Data from another table ( only insert) INSERT INTO Table (col1, col2, col3) SELECT col1, col2, col3 FROM other_table WHERE sql = 'cool' INSERT INTO contacts (contact_id, last_name, first_name) SELECT employee_id, last_name, first_name FROM employees WHERE employee_id <= 100;

    Inserting Multiple values INSERT INTO table1 (First, Last) VALUES ('Fred', 'Smith'), ('John', 'Smith'), ('Michael', 'Smith'), ('Robert', 'Smith');

    To add a column ALTER TABLE table_name ADD column_1 column-definition,column_2 column-definition,column_n column_definition; alter table risk_user_approval_tree add lineusr nvarchar(100); ALTER TABLE table ADD columnname BIT CONSTRAINT Constraint_name DEFAULT 0 WITH VALUES

    To add a auto increment ALTER TABLE 'tableName' ADD 'NewColumn' INT IDENTITY(1,1);

    To add a column with computed value ALTER TABLE dbo.Products ADD RetailValue AS (QtyAvailable * UnitPrice * 1.5);

    To delete/drop a column ALTER TABLE table_name DROP COLUMN column_name;

    To drop a table DROP TABLE tablename;

    To modify a column ALTER TABLE table_name ALTER COLUMN column_name column_type;

    To update a row UPDATE clos_customer_master SET Prev = 'Reactivation' WHERE Prev = 'Reactivate';

    To update a row from select clause UPDATE table SET Col1 = i.Col1, Col2 = i.Col2 FROM ( SELECT ID, Col1, Col2 FROM other_table) i WHERE i.ID = table.ID; The subquery results are substituted into the outer query. As we need table object in outer query, we need to make an alias of inner query.

    To add a primary key ``` ALTER TABLE table_name ADD CONSTRAINT constraint_name PRIMARY KEY (column1, column2, ... column_n);

    ```

    To find the name of constraints SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME = 'tablename'

    To find name of Primary key constraint SELECT name FROM sys.key_constraints WHERE type = 'PK' AND OBJECT_NAME(parent_object_id) = N'CLOS_ext';

    Drop primary key ALTER TABLE table_name DROP CONSTRAINT constraint_name;

    To rename a column (alter command doesnt work here) sp_rename 'table_name.old_column_name', 'new_column_name', 'COLUMN'; sp_rename 'cl_ff_docm.WINAME', 'WI_NAME', 'COLUMN';

    To rename a table sp_rename 'old_table_name', 'new_table_name';

    To top 10% of records SELECT TOP(10) * FROM CLOS_EXT

    To find when a table was altered SELECT [name] , create_date, modify_date FROM sys.tables;

    To find which table contains a given column ``` SELECT * FROM INFORMATION_SCHEMA.COLUMNS;

    SELECT OBJECT_SCHEMA_NAME (c.object_id) SchemaName, o.Name AS Table_Name, c.Name AS Field_Name, t.Name AS Data_Type, t.max_length AS Length_Size, t.precision AS Precision FROM sys.columns c INNER JOIN sys.objects o ON o.object_id = c.object_id LEFT JOIN sys.types t on t.user_type_id = c.user_type_id WHERE o.type = 'U' -- and o.Name = 'YourTableName' ORDER BY o.Name, c.Name 

    ```

    To find which table has which constraint and on which column.

    Select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE;

    Selcting based on case ``` SELECT CASE WHEN <test> THEN <returnvalue> WHEN <othertest> THEN <returnthis> ELSE <returndefaultcase> END AS <newcolumnname> FROM <table>

    Eg. SELECT ProductNumber, Name, "Price Range" = CASE WHEN ListPrice = 0 THEN 'Mfg item - not for resale' WHEN ListPrice < 50 THEN 'Under $50' WHEN ListPrice >= 50 and ListPrice < 250 THEN 'Under $250' WHEN ListPrice >= 250 and ListPrice < 1000 THEN 'Under $1000' ELSE 'Over $1000' END FROM Production.Product ORDER BY ProductNumber ; 

    ```

    Adding row numbers to the result //here we are creating SELECT ROW_NUMBER() OVER(ORDER BY name ASC) AS Row#, name, recovery_model_desc FROM sys.databases WHERE database_id < 5;

    While Loop ``` DECLARE @MaxCount INTEGER DECLARE @Count INTEGER DECLARE @Txt VARCHAR(MAX) SET @Count = 1 SET @Txt = '' SET @MaxCount = (SELECT MAX(RowID) FROM ConcatenationDemo) WHILE @Count<=@MaxCount BEGIN IF @Txt!='' SET @Txt=@Txt+',' + (SELECT Txt FROM ConcatenationDemo WHERE RowID=@Count) ELSE SET @Txt=(SELECT Txt FROM ConcatenationDemo WHERE RowID=@Count) SET @Count += 1 END SELECT @Txt AS Txt

    DECLARE @i int SET @i = 0 WHILE (@i < 10) BEGIN SET @i = @i + 1 PRINT @i IF (@i >= 10) BREAK ELSE CONTINUE END 

    ```

    Try / Catch Statements BEGIN TRY -- try / catch requires SQLServer 2005 -- run your code here END TRY BEGIN CATCH PRINT 'Error Number: ' + str(error_number()) PRINT 'Line Number: ' + str(error_line()) PRINT error_message() -- handle error condition END CATCH

    To get date in DD/MM/YYYY format SELECT CONVERT(varchar, GETDATE(), 103); To get all foreign keys refrencing a given table EXEC sp_fkeys 'TableName'

    To get datatype, size of columns of a table EXEC sp_columns CLOS_EXT;

    To get empty string after concatenation of a string with NULL

    When SET CONCAT_NULL_YIELDS_NULL is ON, concatenating a null value with a string yields a NULL result.

    For example, SELECT 'abc' + NULL yields NULL.

    When SET CONCAT_NULL_YIELDS_NULL is OFF, concatenating a null value with a string yields the string itself (the null value is treated as an empty string).

    For example, SELECT 'abc' + NULL yields abc.

    To compile without executing SET NOEXEC ON; When SET NOEXEC is ON, SQL Server compiles each batch of Transact-SQL statements but does not execute them.

    Updating data from another table UPDATE table SET Col1 = i.Col1, Col2 = i.Col2 FROM ( SELECT ID, Col1, Col2 FROM other_table) i WHERE i.ID = table.ID

    Check if column exists in table IF EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'columnName' AND Object_ID = Object_ID(N'schemaName.tableName')) BEGIN -- Column Exists END

    Converting Multi row data into a comma separated string DECLARE @Names VARCHAR(8000) SELECT @Names = COALESCE(@Names + ', ', '') + ISNULL(Name, 'N/A') FROM People Nvarchar allows storing of unicode data

    To remove duplicate rows select distinct * into t2 from t1; delete from t1; insert into t1 select * from t2; drop table t2;

    Check if the table exists IF (EXISTS ( SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'TheSchema' AND TABLE_NAME = 'TheTable') ) BEGIN --Do Stuff END

    Find tables with given column name select * from INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME like '%clientid%' order by TABLE_NAME

    Find all user tables SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'

    Allows explicit values to be inserted into the identity column of a table. SET IDENTITY_INSERT dbo.Tool ON The DBCC CHECKIDENT management command is used to reset identity counter. Example: DBCC CHECKIDENT ('[TestTable]', RESEED, 0); GO

    DECLARE and SET Varibales DECLARE @Mojo int SET @Mojo = 1 SELECT @Mojo = Column FROM Table WHERE id=1;

    Add a Foreign Key ALTER TABLE Products WITH CHECK ADD CONSTRAINT [FK_Prod_Man] FOREIGN KEY(ManufacturerID) REFERENCES Manufacturers (ID);

    Add a NULL Constraint ALTER TABLE TableName ALTER COLUMN ColumnName int NOT NULL;

    Set Default Value for Column ALTER TABLE TableName ADD CONSTRAINT DF_TableName_ColumnName DEFAULT 0 FOR ColumnName;

    Create an Index CREATE INDEX IX_Index_Name ON Table(Columns)

    Check Constraint ALTER TABLE TableName ADD CONSTRAINT CK_CheckName CHECK (ColumnValue > 1)

    Single Line Comments SET @mojo = 1 --THIS IS A COMMENT

    Multi-Line Comments /* This is a comment that can span multiple lines */

    User Defined Function CREATE FUNCTION dbo.DoStuff(@ID int) RETURNS int AS BEGIN DECLARE @result int IF @ID = 0 BEGIN RETURN 0 END SELECT @result = COUNT(*) FROM table WHERE ID = @ID RETURN @result END GO SELECT dbo.DoStuff(0);

    Pivot - To convert rows into columns SELECT Wi_name, Often, Sometimes, Never, NA FROM ( SELECT Wi_name, Past_due, 'Selected' T, '' F FROM NG_CA_MISCELLANEOUS_DETAILS ) P1 PIVOT ( MAX(T) for Past_due IN ([Often], [Sometimes], [Never],[NA]) ) P2 ORDER BY WI_NAME;

    WITH (NOLOCK)

    is the equivalent of using READ UNCOMMITED as a transaction isolation level. While it can prevent reads being deadlocked by other.

    Finding the last identity inserted into a table

    • @@IDENTITY returns the last identity value generated for any table in the current session, across all scopes. You need to be careful here, since it's across scopes. You could get a value from a trigger, instead of your current statement.

    • SCOPE_IDENTITY() returns the last identity value generated for any table in the current session and the current scope. Generally what you want to use.

    • IDENT_CURRENT('tableName') returns the last identity value generated for a specific table in any session and any scope. This lets you specify which table you want the value from, in case the two above aren't quite what you need (very rare). You could use this if you want to get the current IDENTITY value for a table that you have not inserted a record into.

    @@IDENTITY and SCOPE_IDENTITY will return the last identity value generated in any table in the current session.

    However, SCOPE_IDENTITY returns the value only within the current scope; @@IDENTITY is not limited to a specific scope. That is, if there was a second IDENTITY inserted based on a trigger after your insert, it would not be reflected in SCOPE_IDENTITY, only the insert you performed.

    IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope. For more information, see IDENT_CURRENT.

    Identity doesn't guarantee uniqueness. If you want that, make a PK or add a unique index.

    submitted by /u/ashish2199
    [link] [comments]

    So, where did my git pull wind up?

    Posted: 26 Nov 2017 08:49 PM PST

    If push sends stuff to GitHub, am I right in assuming that a pull is a download? If so, where does it wind up if you don't do anything to specify a location?

    submitted by /u/Mymar
    [link] [comments]

    Wjat would you want to know about a bootcamp before starting?

    Posted: 26 Nov 2017 06:10 PM PST

    There's some mixed feelings about bootcamps here and since I'm considering one and have the opportunity to ask them questions before I make a decision, I ask you, Reddit, what would you want to know before signing on?

    Statistics on graduation and hiring rates are available on their site as well as the curriculum.

    submitted by /u/imamonkeyface
    [link] [comments]

    No comments:

    Post a Comment