Need help with the following: [i'm using SQL Server 2008]
Create a function that accepts a zipcode string (5 characters) as input and returns 1 if thw zipcode is in the zipcode table and 0 if it is not . also create a test file that demonstrates using the function.
I am assuming that the table that contains zipcode information is "location_info" table. Please replace the username, password and databaseName in the defined static variables.
public class TestSQL {
public static void main(String args[]) throws
SQLException {
LocationInfo tsql = new
LocationInfo();
tsql.doesZipCodeExists("12345");
}
}
class LocationInfo {
public final static String databaseName =
"databaseName";
public final static String userName =
"user";
public final static String password =
"pass";
public int doesZipCodeExists(String zipCode)
throws SQLException {
Statement statement =
connectToDB(databaseName, userName, pass);
ResultSet result =
statement.executeQuery("SELECT count(*) as occurences FROM
location_info_table WHERE zip_code = '"+zipCode+"';");
int
isZipCodeAvailable = 0;
if (result.next())
{
int count = result.getInt("occurencces");
if (count >= 1) {
isZipCodeAvailable = 1;
}
}
result.close();
statement.close();
return
isZipCodeAvailable;
}
public Statement connectToDB(String database,
String user, String password) {
try {
String url = "jdbc:sqlserver://localhost:1443;databaseName="+database;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection(url, user, password);
return con.createStatement();
} catch
(ClassNotFoundException | SQLException e) {
System.out.println(e);
}
return null;
}
}
Need help with the following: [i'm using SQL Server 2008] Create a function that accepts a...
Can anyone please help me with these SQL Server Questions? I am using SQL Server 2008 1. Write the code to create two table with at least 10 fields of various data types. 2. Write the code to insert 20 rows of data into the table that you created. 3. Write the code – “Select” statements to write three different reports from your data. 4. Write the code to create a report that incorporates functions. 5. Write the code to...
Please I need help to create a website, using HTML5, that connects to Microsoft SQL Server This what I came up with but I don’t know how to get it to connect to my server? Please help <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#Button1").click(function(){ var database = openDatabase($("#Text1").val(), "1.0", "Contact Manager", 200000); }); }); </script> </head> <body> <span>Enter DataBase Name: <input id="Text1" type="text" /></span> <span> <input...
Complete the following using Microsoft® SQL Server® 2016: Write SQL scripts in Microsoft® SQL Server® for OLTP that include: A Data Definition Language (DDL) script creating the four tables with appropriate data types, primary and foreign keys Data Manipulation Language (DML) scripts that insert a minimum of five records into each table Select scripts showing the full contents of each table Write and run a test script for Step Two. Save a screenshot of the results. Create a 6-page Technical...
Create the function front33 that accepts a string as an argument. The first three letters of the string are added to the front of the string and at the end of the string. If the string length is less than 3, use whatever chars are present. The function takes a string character and returns a new string taking the first three characters of the input string and adding them to the front and the back of the string. (must be...
I need help with my C homework. My teacher has developed a server that generates random characters and numbers. I need to create a program that takes what is generated and put it in standard input form and find the amount of bytes using the sizeof() function. Also, if a random end of file occurs then it should generate a message and how many bytes have come through. Here is an example: or https://gyazo.com/3468f05cf5d50fc62d8f2ac6d988acef Please help soon! Thank You!
Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.
Can someone help me with the following problems please! 6. Write a function that accepts a text file’s name and returns a. The number of uppercase letters in the file b. The number of lowercase letters in the file c. The number of digits in the file d. The number of whitespace characters in the file .
What you're creating Using a case statement, create a function that accepts a letter grade and returns a minimum score to achieve that grade. How you'll do it You learned sequence structure, statements executed in order, then selection statements with if statements, then looping statements. In some languages, there is a case selection statements, sometimes called switch/case. In Python, you can write your own case statement using a function and a dictionary. In this assignment you will write a function...
Homework 4 – Create your own Function Create your own function in C that accepts one input number and returns a double number. The themes for the functions should be one of the following: Calculates 3.14 times of the square of input number. For example, if 2 is input then 12.56 should be returned. (e.g. 3.14*2*2 = 12.56) Divides the number by 3 and returns the result. For example, if 6 was input then 2.0 should be returned....
sql server please help me>>> Create a stored procedure called uspRetrieveOrders that returns all the orders for a last name. It should return first name, last name, item price, discount amount, quantity, the line item extended amount ((ItemPrice-DiscountAmount)*Quantity), the tax amount, and the card type. It should accept LastName as a parameter. Include logic to test if the customer exists in the database. If not, generate an error message. Show the code you used to test the proc.